Skip to content

Instantly share code, notes, and snippets.

View bendyorke's full-sized avatar

Ben Yorke bendyorke

View GitHub Profile
@bendyorke
bendyorke / Colorized Terminal Output
Created June 30, 2013 20:56
How to colorize text in the terminal
//foreground color
public static final String BLACK_TEXT() { return "\033[30m";}
public static final String RED_TEXT() { return "\033[31m";}
public static final String GREEN_TEXT() { return "\033[32m";}
public static final String BROWN_TEXT() { return "\033[33m";}
public static final String BLUE_TEXT() { return "\033[34m";}
public static final String MAGENTA_TEXT() { return "\033[35m";}
public static final String CYAN_TEXT() { return "\033[36m";}
public static final String GRAY_TEXT() { return "\033[37m";}
/* Here is your chance to take over Socrates!
Spend 10 minutes on each of the following hacks to the socrates website.
Enter them in the console to make sure it works and then save
your results here.
Choose a new pair for each. Add your names to the section you complete.
*/
@bendyorke
bendyorke / index.html
Last active December 19, 2015 07:19 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>
@bendyorke
bendyorke / zoo.js
Last active December 19, 2015 07:29 — forked from dbc-challenges/zoo.js
//------------------------------------------------------------------------------------------------------------------
// YOUR CODE: Create your Zoo "object literal" and Animal "constructor" and "prototypes" here.
//------------------------------------------------------------------------------------------------------------------
var Zoo = {
animals: {},
init: function(animalInput) {
for(index in animals) {
this.animals[animalInput[index].name] = animalInput[index].legs;
};
@bendyorke
bendyorke / gist:6059481
Created July 23, 2013 02:46
form_snippet
<snippet>
<content><![CDATA[
<form action="/${1:url}" method="post">
<input type="${2:text}" name="$3">
<input type="${4:password}" name="$5">
${6:<input type="submit" value="Submit">}
</form>$0
]]></content>
<tabTrigger>frmzplz</tabTrigger>
<scope>text.html - ruby</scope>
module GameOfLife
def self.play input, n
# return 42 if input == "the universe and everything"
@board = make_board_from input
n.times { age!; print_board; sleep(0.2) }
end
def self.age!
results = parse_cells
process results
@bendyorke
bendyorke / benchmark.rb
Created May 20, 2014 06:54
Benchmarking sampling of a hash
require "benchmark"
n = 10000
arr = (1..1000).to_a
zip = arr.zip arr
hash = Hash[zip]
Benchmark.bm do |x|
x.report("%-30s" %["sampling array"]) { n.times do
arr.sample
@bendyorke
bendyorke / setup.md
Last active March 12, 2021 14:25
Setting up a new mac
@bendyorke
bendyorke / todo
Last active August 29, 2015 14:04
#!/usr/bin/env python
"""http://stevelosh.com/projects/t/#installing-t | http://bitbucket.org/sjl/t/"""
"""t is for people that want do things, not organize their tasks."""
from __future__ import with_statement
import os, re, sys, hashlib
from operator import itemgetter
from optparse import OptionParser, OptionGroup
@bendyorke
bendyorke / zero_to_clojure.clj
Last active May 13, 2016 21:11
Fully featured clojure web server in 10 lines of code
#! /usr/bin/env boot
(set-env! :dependencies '[[compojure "1.5.0"]
[http-kit "2.1.8"]])
(require '[compojure.core :refer [defroutes GET]])
(require '[org.httpkit.server :refer [run-server]])
(defroutes routes
(GET "/" [] "Hello World!"))