GitHub API and JSONP support is a nice way, how to play with those data in browsers.
I wanted to have a GitHub timeline on my personal website, instead of the Twitter timeline. After some hacking, I came out with this: https://github.com/todvora/gh-events-widget
That's surprisingly readable for someone having coded less than a year. Granted, it's only about a 100 lines so not that much complexity, but still separated into smaller, readable functions.
I think it took several years before I started doing that. Maybe the new age of having everything shared on GitHub makes one focus earlier on maintainability and readability for others?
Brava! Very clean and thoughtful architecture, especially impressive given your short history with code, and that humbles me, an "old guy" compared to most of the readers here. Well done.
If you're not 100% sure that the GitHub data fields (bio, name, etc) are stripped of markup, please ensure that your widget isn't vulnerable to cross-site scripting (XSS).
There are GitHub users whose bios, names, etc contain HTML fragments. The way that your code inserts those fields is likely to be vulnerable. It's better to explicitly treat the fields as text, e.g. by using jQuery's text() method.
It would be very handy to know what is a 'must have list' when
implementing those kind of widgets, does anyone came across anything like this? I mean what I shall be aware in terms of XSS, security in overall and best practises.
Bad programming advice. jQuery uses best practices for many utility functions. Developers should not have to reinvent the wheel or code every basic call from scratch in every project. Don't act like using pre-built common frameworks is somehow a bad idea for ideal programming. They are reliable and faster, its one less issue to worry of what could be wrong.
- A friend of mine once made an experience: He sent his CV applying for a not gender biased kind of job. No answer. Then he sent an equivalent CV but pretending to be a fairly attractive female (with a cool photo) applying for the same job. Few days later 'she' was asked for an interview.
- I have another friend that is responsible for HR on a small business (not rocket science kind of job). While bachelor he used to select possible hires by photo. His boss was aware of it and wouldn't oppose, treating it as a kind of 'perk' for my friend..
TLDR: Humans seem to be more helpful to potential attractive mates.
Nice job!
One suggestion from a person who developed widgets used on lots of sites: You are appending general styles (like styling the a tag, ".container" which is a popular class name) to the containing document's body. This is bad practice, since it will alter all the links on the containing page. Consider using namespaced classes (like .github-widget-link) or build your own iframe and apply the styling there
- Use a tool like EsLint to lint your code. It will make it more readable and cleaner than it is right now. Maybe integrate your editor with Eslint and it will guide you to write cleaner code.
- You can use underscore templating to inject variables in the template and it will be much more cleaner and maintainable. http://underscorejs.org/
note: I haven't filed it as bug yet, as I am unsure about the reason yet. But when I user data-username="gbraad" I do not see the correct Top repositories. At the top should have been 'gauth' (with 582 stars). When using the widget I see `blog` (with 7 stars). Might be because pinned repositories has been customized?
This isn't good advice. jQuery will get those variables just as fast. You're really splitting hairs just for the sake of criticizing. http://www.stoimen.com/blog/2010/06/19/speed-up-the-jquery-c...
Basic developers should not care about such minor differences and write code they can read & maintain. $("") stands out as a DOM element, and who wants to add an extra line for variables -- unneeded and tedious. Most developers should not have to worry "oops did i cache declare everything beforehand" or act as ifs a bad coding practice that 'takes points' in the final code
Have you even read the article you linked to? Maybe you should read the comments on the article as well...
I've experienced this in many web apps, which had major benefit from these changes. The same applies to managed code (C#), where just being mindful about how and what you write, makes everything faster.
Nice work. :) This reminds me of an ID card generator I made for Orkut profile using PHP and its GD library. It was a 200 Lines of hack job when I didn't even understand the concept of breaking code into functions. Sadly, I used to feel so embarrassed by my old code that I thought it was a good idea to erase it; wish I hadn't. :(
Lesson learned : Don't delete your old creative memories even if they are ridiculous.
Do you find this idea to be that revolutionary? (I guess not as someone linked other similar project (and you downvoted him))
Do you find this project in particular to be that interesting? (Doubt it with the scope of this project)
Not to take anything away from the effort that went into creating this, but judging from the history of (Show HN) posts that reach the front page, this is HIGHLY unusual.
Also of interest is the number of emoticons /:)/ in here - 25% of comments contain one, compared to other Show HN posts with 8.3%, 6% or general posts with 1.5%, 0.5%, 0%, ...
I looked at the data and did not see that. Assuming that voting is "rigged" on a submission just because you don't approve of it is nearly always a non sequitur.
Also, please don't create many obscure throwaway accounts on HN. This forum is a community. Anonymity is fine, but users should have some consistent identity that other users can relate to. Otherwise we may as well have no usernames and no community, and that would be an entirely different forum.
Personally I flagged this - there are good sites for codereview e.g. http://codereview.stackexchange.com/ but I don't think HN is, or should be one of them.
There's nothing wrong with posting a learning project as a Show HN. There's a long tradition of doing so, and in this case the submission title made it super clear.
I'm afraid it's your comment that's out of line. I don't think you intended it this way (and we appreciate your concern for the quality of HN), but in this context it comes across as squashing someone for their work, which combined with the automatic upvotes that negative comments sadly get, gives a rude and unpleasant impression of this community. Who would want to be part of a place that disses beginners?
I was actually implying that the submission was not upvoted solely because of its content. Because, let's be frank, the content is not worth to be the top submission on HN when compared to what one can usually find there. Even the "learning" angle does not cut it.
And it's not getting anything away from the post, rather from the praise it got. The post itself is perfectly fine (and as such I didn't flag it).
Please don't submit comments complaining that a submission is inappropriate for the site. If you think a story is spam or off-topic, flag it by clicking on its 'flag' link. If you think a comment is egregious, click on its timestamp to go to its page, then click 'flag' at the top. (Not all users see flag links; there's a small karma threshold.)
Also of interest is the number of emoticons /:)/ in here - 25% of comments contain one, compared to other Show HN posts with 8.3%, 6% or general posts with 1.5%, 0.5%, 0%, ...
I think it's more the (learning to code) that brings out the good in people. While I wouldn't want HN to be full of Show HNs like this, it's cool to once in a while take a step back and remember where oneself began.
I wonder why it can't be both (a woman dev + learning how to program) instead of either/or. I suspect it's a combination of both. I don't think there's anything wrong with subs like this.
I totally disagree. Inflammatory and insulting? Could you please explain?
Did I hurt or offend someone? I see no one complaining here but you.
If you're smart enough to open a web browser you should expect to find, recognize and accept a joke.. because you know .. you'll find lots of this in the web.
And I don't really feel like I was wrong at all: If you check the thread carefully, I wasn't the only one pointing this out. I just opted to make a joke about it really.
If you think oppression works well for you, then please feel free, by any means available to you, to ban my account.
That's your interpretation of a flagged comment. You have absolutely no data to support that my comment was flagged due to inappropriate content and people complaining about it.
As far as I'm concerned it's just people who can't stand a joke.
76 comments
[ 4.5 ms ] story [ 127 ms ] threadI remember creating something similar ( not as polished as this ) at a Yahoo! Hack Day, when I was new to coding.
I wanted to have a GitHub timeline on my personal website, instead of the Twitter timeline. After some hacking, I came out with this: https://github.com/todvora/gh-events-widget
I think it took several years before I started doing that. Maybe the new age of having everything shared on GitHub makes one focus earlier on maintainability and readability for others?
If you're not 100% sure that the GitHub data fields (bio, name, etc) are stripped of markup, please ensure that your widget isn't vulnerable to cross-site scripting (XSS).
There are GitHub users whose bios, names, etc contain HTML fragments. The way that your code inserts those fields is likely to be vulnerable. It's better to explicitly treat the fields as text, e.g. by using jQuery's text() method.
It would be very handy to know what is a 'must have list' when implementing those kind of widgets, does anyone came across anything like this? I mean what I shall be aware in terms of XSS, security in overall and best practises.
If you aren't getting a lot of use out of the features it provides then you are better off without such a heavyweight dependency.
Suggestion: you're getting a lot of good feedback here. Might be good to create issues on the project. You'll likely get some takers too.
To HN community: good to see that people here are humans. It's amazing how a cool pic can trigger so many comments and upvotes :)
- I have another friend that is responsible for HR on a small business (not rocket science kind of job). While bachelor he used to select possible hires by photo. His boss was aware of it and wouldn't oppose, treating it as a kind of 'perk' for my friend..
TLDR: Humans seem to be more helpful to potential attractive mates.
- Use a tool like EsLint to lint your code. It will make it more readable and cleaner than it is right now. Maybe integrate your editor with Eslint and it will guide you to write cleaner code.
- You can use underscore templating to inject variables in the template and it will be much more cleaner and maintainable. http://underscorejs.org/
note: I haven't filed it as bug yet, as I am unsure about the reason yet. But when I user data-username="gbraad" I do not see the correct Top repositories. At the top should have been 'gauth' (with 582 stars). When using the widget I see `blog` (with 7 stars). Might be because pinned repositories has been customized?
If you need $(".stats") four times, don't repeat that four times, but do:
and use the variable. Especially when using class selectors.End result looks good; keep on hacking :)
N.B.
Same is true for indexers (and allows you to refactor the code easier later on);
Instead of:
Consider:I've experienced this in many web apps, which had major benefit from these changes. The same applies to managed code (C#), where just being mindful about how and what you write, makes everything faster.
Lesson learned : Don't delete your old creative memories even if they are ridiculous.
Do you find this idea to be that revolutionary? (I guess not as someone linked other similar project (and you downvoted him))
Do you find this project in particular to be that interesting? (Doubt it with the scope of this project)
Not to take anything away from the effort that went into creating this, but judging from the history of (Show HN) posts that reach the front page, this is HIGHLY unusual.
Also of interest is the number of emoticons /:)/ in here - 25% of comments contain one, compared to other Show HN posts with 8.3%, 6% or general posts with 1.5%, 0.5%, 0%, ...
To answer these questions, we must only look into the mirror.
Also, please don't create many obscure throwaway accounts on HN. This forum is a community. Anonymity is fine, but users should have some consistent identity that other users can relate to. Otherwise we may as well have no usernames and no community, and that would be an entirely different forum.
Personally I flagged this - there are good sites for codereview e.g. http://codereview.stackexchange.com/ but I don't think HN is, or should be one of them.
I'm afraid it's your comment that's out of line. I don't think you intended it this way (and we appreciate your concern for the quality of HN), but in this context it comes across as squashing someone for their work, which combined with the automatic upvotes that negative comments sadly get, gives a rude and unpleasant impression of this community. Who would want to be part of a place that disses beginners?
wrt "dissing beginners", the post explicitly says: "Not to take anything away from the effort that went into creating this".
The reason posts like this are upvoted is to protect discourse from the neg-police.
And it's not getting anything away from the post, rather from the praise it got. The post itself is perfectly fine (and as such I didn't flag it).
Quality is multi-dimensional.
Shhh.. it's a girl.. men are excited!
We detached this subthread from https://news.ycombinator.com/item?id=12164429 and marked it off-topic.
Did I hurt or offend someone? I see no one complaining here but you.
If you're smart enough to open a web browser you should expect to find, recognize and accept a joke.. because you know .. you'll find lots of this in the web.
And I don't really feel like I was wrong at all: If you check the thread carefully, I wasn't the only one pointing this out. I just opted to make a joke about it really.
If you think oppression works well for you, then please feel free, by any means available to you, to ban my account.
Users flagged your post. That's people complaining.
That's your interpretation of a flagged comment. You have absolutely no data to support that my comment was flagged due to inappropriate content and people complaining about it.
As far as I'm concerned it's just people who can't stand a joke.