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
#!/bin/bash | |
read -s -p "GitHub password: " pass | |
# I assume the GitHub API and authentication works because I don't want to parse JSON | |
curl -u "yefim323:$pass" https://api.github.com/user/repos -d "{\"name\":\"$1\"}" > /dev/null | |
git remote add origin [email protected]:yefim323/$1.git |
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 sort_by_freq = function(str) { | |
var i, j; | |
var map = []; | |
var sorted = []; | |
for (i = 0; i < str.length; i++) { | |
if (map[str.charAt(i)] == null) { | |
map[str.charAt(i)] = 1; | |
} else { | |
map[str.charAt(i)] = map[str.charAt(i)] + 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
class Q | |
constructor: (@bound) -> | |
@offset = 0 | |
@length = 0 | |
@data = [] | |
enqueue: (value) -> | |
return undefined if @length == @bound | |
@data.push value | |
++@length | |
dequeue: -> |
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
// Count all of the links from the nodejs build page | |
var jsdom = require("jsdom"); | |
jsdom.env( | |
"http://nodejs.org/dist/", | |
["http://code.jquery.com/jquery.js"], | |
function (errors, window) { | |
$ = window.$; | |
console.log("there have been " + $("a").length + " nodejs releases!"); | |
} |
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
#include <iostream> | |
#include <string> | |
#include "doublell.h" | |
using namespace std; | |
DoubleLL::DoubleLL() | |
{ | |
head = NULL; | |
tail = NULL; |
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
merge = (a, p, q, l) -> | |
L = a[p..q] | |
R = a[q+1..l] | |
L.push Infinity | |
R.push Infinity | |
i = 0 | |
j = 0 | |
for k in [p..l] | |
if L[i] <= R[j] | |
a[k] = L[i] |
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
# G = [vertices] | |
# vertex = { | |
# adjacency_list: [vertex_ids] | |
# color: one of ["WHITE", "GRAY", "BLACK"] | |
# parent: vertex | |
# d: depth | |
# } | |
module.exports = | |
test: -> |
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
# G = [vertices] | |
# vertex = { | |
# adjacency_list: [vertex_ids] | |
# color: one of ["WHITE", "GRAY", "BLACK"] | |
# parent: vertex | |
# d: discovery time | |
# f: finish time | |
# } | |
DFS_VISIT = (G, u) -> |
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
partition = (A, p, l) -> | |
x = A[l] | |
i = p - 1 | |
for j in [p..l-1] | |
if A[j] <= x | |
i++ | |
[A[i], A[j]] = [A[j], A[i]] | |
[A[i+1], A[l]] = [A[l], A[i+1]] | |
return i + 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
contestant = { | |
start_game: (configs) -> | |
@guesses = [0..configs.game_size-1] | |
guess_index: (input) -> | |
i = Math.floor(Math.random() * @guesses.length) | |
@guesses.splice(i, 1)[0] | |
} |
OlderNewer