This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const counter = (state=0, action) => { | |
| switch (action.type) { | |
| case 'INCREMENT': | |
| return state + 1; | |
| case 'DECREMENT': | |
| return state - 1; | |
| default: | |
| return state; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var a, b, rest; | |
| [a,b] = [1,2]; | |
| console.log(a); // 1 | |
| console.log(b); // 2 // wow, so convenient! will I remember to do this, or not bother? | |
| [a, b, ...rest] = [1, 2, 3, 4, 5]; | |
| console.log(a); // 1 | |
| console.log(b); // 2 | |
| console.log(rest); // [3, 4, 5] // incredible... although now I'm thinking this is nearly illegible for other developers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Trapezoid tabs | |
| */ | |
| body { | |
| padding: 40px; | |
| font: 130%/2 Frutiger LT Std, sans-serif; | |
| } | |
| nav { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var TweetBox = React.createClass({ | |
| getInitialState: function() { | |
| return { | |
| text: "", | |
| photoAdded : false, | |
| }; | |
| }, | |
| togglePhoto : function(event) { | |
| this.setState({ photoAdded: !this.state.photoAdded }) | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Text (asText) | |
| type Collection a = Nada | Glue a (Collection a) | |
| summm xs = | |
| case xs of | |
| Nada -> 0 | |
| Glue face body -> face + (summm body) | |
| listToCollection collection = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Sinatra | |
| module Kittens | |
| module Helpers | |
| def kittens_page(x = 200..500, factor = 0.2) | |
| sample_method = RUBY_VERSION >= '1.9' ? :sample : :choice | |
| x = x.to_a.send(sample_method) | |
| y = ((x - factor*x).floor..(x + factor*x).ceil).to_a.send(sample_method) | |
| <<-HTML | |
| <!DOCTYPE html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function sum (numbers) { | |
| return !numbers.length ? 0 : numbers[0] + sum(numbers.slice(1)); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Maybe a = Nothing | Just a | |
| type Option a = None | Some a | |
| type Result a = Failure | Success a | |
| max [] ----> Failure | |
| max [1,2,3] -----> Success 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| textarea:focus, | |
| input[type="text"]:focus, | |
| input[type="password"]:focus, | |
| input[type="datetime"]:focus, | |
| input[type="datetime-local"]:focus, | |
| input[type="date"]:focus, | |
| input[type="month"]:focus, | |
| input[type="time"]:focus, | |
| input[type="week"]:focus, | |
| input[type="number"]:focus, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class GuessTheNumber | |
| def play | |
| @nnn = 1.upto(100).to_a.sample | |
| # play game | |
| puts "Alright, I have a number in mind from 1-100. Pick a number." | |
| guess = gets.chomp | |
| puts "You said #{guess}." | |
| attempt guess | |
| end |