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
# Run git status if in git repo, else ls -la | |
function cs { | |
clear | |
if ! git ls-files >& /dev/null | |
then | |
ls -la | |
else | |
git status | |
fi | |
} |
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 lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Bash Command Visualization</title> | |
<style type="text/css"> | |
* { margin: 0; padding: 0; } | |
#chart { |
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 lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>D3 Page Template</title> | |
<style> | |
* { margin: 0; padding: 0; } | |
body { padding: 30px; } |
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
// JSON structure: | |
{ | |
"countries" : [ | |
{ "name": "CountryName", "alternatives": "One Two" }, | |
{ ... } | |
] | |
} | |
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 methods = ['one', 'two'], | |
test = {}; | |
for (var i=0; i<methods.length; i++) { | |
var name = methods[i]; | |
test[name] = function() { console.log(name); } | |
} | |
test.one() // 'two' |
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 x = 0; | |
function test() { | |
x = 1; | |
y = 2; | |
var z = 3; | |
} | |
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
counts = Hash.new(0) | |
File.read("#{Dir.home}/.bash_history").each_line do |line| | |
cmd = line.split.first | |
if cmd == "git" | |
cmd = line.split.take(2).join("_") # git_push | |
end | |
counts[cmd] += 1 | |
end | |
counts.sort_by { |key, value| value }.reverse.each do |cmd, count| |
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 rotateMatrix(matrix, numRot) { | |
var result = [], | |
buf = []; | |
if (numRot != 0) { | |
for (var i=0; i<matrix.length; i++) { | |
for (var j=0; j<matrix.length; j++) { | |
buf.push(matrix[j][i]) | |
} | |
result.push(buf.reverse()) |
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
Brainfuck (http://en.wikipedia.org/wiki/Brainfuck) is an strange language noted for its extreme simplicity - programs are written using 7 commands in total, and executed sequentially. | |
An 'instruction pointer' starts at the first command, executes it, and normally moves forward to the next command (with one exception). | |
The program terminates when the instruction pointer moves past the last command. | |
For those familiar with Turing machines, this is a very similar concept. We'll have a 'tape' of cells holding our values, a pointer to the current cell, and an instruction pointer looping through the program. | |
The commands we'll be working with are as follows (here, 'pointer' refers to the current cell pointer): | |
> Move the cell pointer to the cell on the right | |
< Move the cell pointer to the cell on the left |