Re:Show HN: My weekend project - Codestagram
by imkevinxu on Wednesday January 02, 2013 @03:23PM
(#4999031)
I feel like I found what you are looking for from Coderwall's blogs, they tend to be short interesting snippets by language and sorted by popularity.
https://coderwall.com/n/python https://coderwall.com/n/ruby https://coderwall.com/n/haskell
Re:Show HN: My weekend project - Codestagram
by randomdrake on Wednesday January 02, 2013 @05:00PM
(#4999571)
Hyperpolyglot has some of this stuff. It doesn't provide particularly rich and deep examples, but it is an easily scannable list of small code snippets. If you haven't seen it already, you should take a look.
Re:Show HN: My weekend project - Codestagram
by xxpor on Wednesday January 02, 2013 @04:13PM
(#4999347)
Quick question: wouldn't 1?1:var always return 1?
Re:Show HN: My weekend project - Codestagram
by JoeCortopassi on Wednesday January 02, 2013 @04:58PM
(#4999558)
Nope. Having '1' as the condition in the ternary operator, causes 'var' to never be evaluated (to avoid accidental operations with getters and such), but the compiler allows the 'var' to affect if the '1' is treated as a float or an int. Here's a breakdown:
if var is a float...
(1?1:var)/2
...becomes... (1.0/2)
...which equals 0.5 and is considered true when evaluated. But if var is an int... (1?1:var)/2
...becomes... (1/2)
...which equals 0 and is considered false when evaluated
Re:Show HN: My weekend project - Codestagram
by Groxx on Friday January 04, 2013 @12:01AM
(#5006345)
Is that part of the spec for coercions, or is it exploiting a typical compiler's behavior? It certainly doesn't appear to be a required way to process that statement (optimizations could remove the 'if' portion entirely), unless it is actually required of the compiler.
############~C~#############
#######~Objective-C~######## #########~PHP~############## ############################I know they aren't the best example, but I would love to be able to scan through a list of small code snippets (by language) that demonstrate concepts. On the plus side, it would be an easier way to show some competence in a language (for future employers) than having to do massive contributions to open source projects (don't have that much free time). The thing that makes or breaks this project is a smallish limit on lines. Without it, you are just another Gist/Pastebin, without the benefits of the wide user base and additional features. I have zero desire to chill at night and scan through a bunch of random 100+ line snippets that I have no context for, but I love goofing around on Stackoverflow, looking at fancy code snippets