Skip to content

Instantly share code, notes, and snippets.

Avatar

Teejay VanSlyke teejayvanslyke

View GitHub Profile
View set-state-doesnt-immediately-mutate-state-fix.js
handleChange(event) {
this.setState({ message: event.target.value }, () => {
console.log(this.state)
});
}
View set-state-doesnt-immediately-mutate-state.js
class MyForm extends React.Component {
constructor(props) {
super(props);
this.state = { message: "Hello, World" };
}
render() {
const input = React.createElement('input', {
type: 'text',
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script src="https://fb.me/react-15.1.0.js"></script>
<script src="https://fb.me/react-dom-15.1.0.js"></script>
View gist:5600011
var suits = ["Hearts", "Spades", "Clubs", "Diamonds"];
var faces = ["Ace", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"];
var cards = []
for (var s=0; s<suits.length; s++) {
for (var f=0; f<faces.length; f++) {
cards.push({suit: suits[s], face: faces[f]});
}
}
View Poker Playing Program (Still in development...)
<html>
<head>
<title>Shuffle</title>
<script>
//BUILD DECK
var suit = ["Hearts", "Spades", "Clubs", "Diamonds"]; // Create the suit array
var face = ["Ace", "1", "2", "3", "4", "5", "6", "7", // Creat face array
"8", "9", "10", "Jack", "Queen", "King"];
//GENERATE RANDOM VALUES FOR 5 DIFFERENT CARDS
View gist:2569284
$('a[data-mixpanel-tracker]').click ->
setTimeout (=> window.location.href = $(@).attr('href')), 300
tracker = $(@).attr('data-mixpanel-tracker')
properties = JSON.parse($(@).attr('data-mixpanel-properties') || '{}')
mixpanel.track tracker, properties
return false
@teejayvanslyke
teejayvanslyke / backbone-jasmine-event-matcher.coffee
Created Mar 21, 2012
Jasmine matcher for Backbone.Event expectations
View backbone-jasmine-event-matcher.coffee
# Usage:
#
# @model.doSomething = ->
# @other_model.trigger('something_done', 'somearg')
#
# expect(=> @model.doSomething()).toTrigger('something_done', on: @other_model, with: [ 'somearg' ])
#
beforeEach ->
View gist:1099904
888888b. 888 d8888 888b d888 888
888 "88b 888 d88888 8888b d8888 888
888 .88P 888 d88P888 88888b.d88888 888
8888888K. 888 d88P 888 888Y88888P888 888
888 "Y88b 888 d88P 888 888 Y888P 888 888
888 888 888 d88P 888 888 Y8P 888 Y8P
888 d88P 888 d8888888888 888 " 888 "
8888888P" 88888888 d88P 888 888 888 888
View gist:670076
[20192, 24060, 20758, 21904, 1548, 24285, 20202, 23260, 2111, 24166, 20344, 21269, 22157, 20887, 23735, 23016, 22138, 22869, 23699, 21398, 22203, 20805, 21338, 22110, 23043, 24115, 23388, 20332, 1624, 1523, 24250, 21325, 20381, 1258, 21115, 20752, 21135, 22373, 2020, 23846, 20867, 21672, 21818, 23675, 1854, 20388, 1556, 853, 23313, 1378, 23495, 20333, 24045, 20711, 20795, 22530, 22109, 20397, 24255, 22815, 21160, 1688, 20015, 2097, 20281, 21027, 23725, 22616, 22407, 23907, 23954, 20580, 1903, 21017, 1714, 22251, 21708, 21710, 22229, 20204, 22282, 1660, 23230, 22429, 22895, 23179, 20343, 23383, 1288, 22494, 1776, 20982, 22186, 23196, 21258, 1622, 21172, 22805, 20476, 24286, 21652, 1470, 22271, 20839, 23860, 21615, 805, 21204, 22148, 21670, 23136, 20207, 20767, 23109, 21254, 20985, 24208, 23653, 20654, 23037, 21622, 22248, 23899, 20541, 22491, 1798, 20843, 1477, 20937, 1584, 21187, 1184, 22310, 22082, 22227, 23969, 23272, 21567, 22412, 22260, 20932, 22255, 1227, 21501, 22931, 24071, 1606, 21089, 23910, 1293, 21
View gist:622512
require 'csv'
path = 'db/registered_students_fall_2010.csv'
row_index = 0
created_after_9_1 = YAML::load_file('db/created_after_9_1.yml')
p created_after_9_1.size
results = []
You can’t perform that action at this time.