Skip to content

Instantly share code, notes, and snippets.

View biglovisa's full-sized avatar
🌍
Patch is hiring!

Lovisa Svallingson biglovisa

🌍
Patch is hiring!
View GitHub Profile
@biglovisa
biglovisa / enums.md
Last active February 24, 2016 15:23
Posse Challenge week 4, February 22 2016

Enumerables

An enumerable is an object that may be enumerated. "Enumerated" means to count off the members of a set/collection/category one by one (usually in order, usually by name).

"Enumerable" is Ruby's way of saying that we can access each element in a collection, one at a time. Enumerable is a mixin in the Array class and it provides several enumerators such as each, map, select and many more. Find all enumerables and enumerators in the Ruby docs.

Ruby has a tons of enumerables which means that if we pick the right enumerable for the job, our implementation will be very clean and easy to read.

This week we are going to be writing enumerables from scratch. The groups are only allowed to use each, until loops, while loops and for loops.

// aka root component
var Dashboard = React.createClass({
getInitialState: function() {
return { headerIsActive: false }
},
onButtonClick: function() {
console.log('in DASHBOARD!!');
},
@biglovisa
biglovisa / pokemon.rb
Created February 12, 2016 16:02
pokemon-cli
require "net/http"
require "json"
require "pry"
class PokemonService
def pokemon_information(info)
path = "pokemon/#{info}"
send_request(path: path)
end
@biglovisa
biglovisa / js-1.js
Last active February 9, 2016 15:57
js-challenge-1
//------------------------------------------------------------- Split the string on new lines
var text = "What are you talking about?"
split(text);
// #=> ["What", "are", "you", "talking", "about?"]
//------------------------------------------------------------- Reverse the order of the words
var text = "What are you talking about?"
reverseOrder(text);
@biglovisa
biglovisa / 2016-01-07.md
Created January 7, 2016 16:52
January 7 2016
@biglovisa
biglovisa / old-vs-new.js
Last active December 18, 2015 16:48
Old vs New React class syntax
/// Older
///////////// Here, we specify the defaultProps and the initialState in functions in the component
///////////// We also validate the component props in the propTypes function
var Counter = React.createClass({
getDefaultProps: function(){
return {initialCount: 0};
},
getInitialState: function() {
return {count: this.props.initialCount}