This file contains 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 fill = curry((thing, start, end, data) => Array.prototype.fill.call(data, thing, start, end)); | |
const shuffle = curry(data => data); | |
const chunk = curry(function group(n, list) { | |
return R.isEmpty(list) ? [] : R.prepend(R.take(n, list), group(n, R.drop(n, list))); | |
}); | |
pipe( | |
fill(0, 9, 71), | |
fill(1, 0, 9), | |
shuffle, |
This file contains 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 Ember from 'ember'; | |
export default Ember.Component.extend({ | |
actions: { | |
act() { | |
console.log('this is what we want hit'); | |
} | |
} | |
}); |
This file contains 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 Ember from 'ember'; | |
export default Ember.Component.extend({ | |
init: function(){ | |
this._super(); | |
setTimeout(() => { | |
if (!(this.isDestroyed || this.isDestroying)) { | |
Ember.run(() => { | |
this.set('message', 'bar'); | |
}); |
This file contains 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() { | |
var params = /(?:&|\?)(.+)/g.exec(window.location.href); | |
var paramsObj = {}; | |
if (params && Object.keys(params).length) { | |
params[1].split('&').forEach(function(strPair) { | |
var splitPair = strPair.split('='); | |
paramsObj[splitPair[0]] = splitPair[1]; | |
}); | |
} |
This file contains 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 util.Random.nextInt | |
var choices = Array("rock", "paper", "scissors"); | |
var results = Array("Draw!", "Player wins!", "Computer wins!"); | |
def judge (humanChoice:String, computerChoice:String) = { | |
val humanIndex = choices.indexOf(humanChoice); | |
val computerIndex = choices.indexOf(computerChoice); | |
val resultIndex = (3 + humanIndex - computerIndex) % 3; | |
results(resultIndex); |
This file contains 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 balanceA(arr) { | |
var filtered = arr.filter(function(item) { | |
return item.match(/(\(|\))/g) | |
}); | |
function test(a) { | |
// these conditions are insane, there must be a far easier way of doing this... |
This file contains 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 sumNonRecursive(arr) { | |
var n = 0; | |
for (var i = 0; i < arr.length; i++) { | |
n = n + arr[i]; | |
} | |
return n; | |
} | |
var numArray = [5,2,3]; |
This file contains 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
str.match(/(?:jpg|png|gif)/) |
This file contains 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 fs = require('fs'), | |
net = require('net'); | |
var writeStream = fs.createWriteStream(__dirname + "/outfile.txt"); | |
var server = net.createServer(function (socket) { | |
socket.on('data', function(data) { | |
socket.write(data); | |
writeStream.write(data); | |
console.log(data); |
This file contains 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
<!doctype html> | |
<html> | |
<head> | |
<title>JS1k, 1k demo submission [ID]</title> | |
<meta charset="utf-8" /> | |
</head> | |
<body> | |
<canvas id="c" height=300></canvas> | |
<script> | |
// boilerplate... |