Skip to content

Instantly share code, notes, and snippets.

View es's full-sized avatar
🐢
waiting for the cache to expire

Emil Stolarsky es

🐢
waiting for the cache to expire
View GitHub Profile
@es
es / FisherYatesShuffle.js
Last active December 27, 2015 06:49
In place Fisher-Yates shuffle in Javascript.
function FisherYatesShuffle (arr) {
var randInt = function (min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
};
var swap = function (pos1, pos2) {
var temp = arr [pos1];
arr [pos1] = arr [pos2];
arr [pos2] = temp;
};
@es
es / buildVagrantRuby.sh
Created November 15, 2013 05:02
Build script for a new dev machine when working with ruby.
#!/usr/bin/env bash
apt-get update
apt-get install -y nginx vim make g++ postgresql-9.1 curl libxslt-dev libxml2-dev libsqlite3-dev
\curl -L https://get.rvm.io | bash -s stable
source /usr/local/rvm/scripts/rvm
rvm requirements
rvm install ruby
rvm use ruby --default
rvm rubygems current
gem install rails
@es
es / functional.js
Created December 8, 2013 20:55
Implementation of Curry, Uncurry, & Compose functions (with accompanying tests).
/*
* Curry takes a two argumented function and returns one func that returns a second func that each take one argument.
*/
function curry (func) {
return function (x) {
return function (y) {
return func (x, y);
};
};
@es
es / README.md
Last active December 30, 2015 23:39 — forked from wbzyl/README.md

SVG Essentials – Filters

This is a recreation (for the purpose of tinkering with an implementation in d3.js) of the example from the book SVG Essentials by J. David Eisenberg.

The <feColorMatrix> element allows to change color values in a following way.

@es
es / permutate.js
Created December 21, 2013 22:49
Returns an array with all the permutations of the array passed.
function permutate (arr) {
var permutations = [];
function helper (list, perm) {
var currentLength = perm.length;
if (perm.length === arr.length) {
return permutations.push(perm);
}
else {
for (var i = 0, len = list.length; i < len; i++) {
@es
es / PriorityQueue.js
Created December 28, 2013 05:32
PriorityQueue written in Javascript
/*
* Method Definition taken from Programming Challenges by Skiena and Revilla
* Insert(x,p) — Insert item x into priority queue p.
* Maximum(p) — Return the item with the largest key in priority queue p.
* ExtractMax(p) — Return and remove the item with the largest key in p.
*/
function PriorityQueue (arr) {
this.arr = arr || [];
}
@es
es / BayesClassifier.js
Created January 12, 2014 01:29
A BayesClassifier written by following the tutorial written by Burak Kanber. http://burakkanber.com/blog/machine-learning-naive-bayes-1/
"use strict";
var BayesClassifier = function () {
this.labels = {};
this.words = {};
this.docNum = 0;
this.tokenize = function (doc) {
var temp = doc.toLowerCase().replace('.','')
.replace(',','')
.replace('\'','')
@es
es / Dockerfile
Created July 16, 2014 15:29
Oracle Java 7 Dockerfile
FROM ubuntu:12.04
# Setup basic Instance
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y python-software-properties python
RUN apt-get install -y software-properties-common
# Download Java
@es
es / laptop.local
Last active August 29, 2015 14:05
Customizations for Thoughtbot's Laptop (~/.laptop.local)
#!/bin/sh
## Apps
brew tap caskroom/cask
brew install brew-cask
# Internet
brew cask install google-chrome
brew cask install firefox
brew cask install silverlight
@es
es / Cheffile
Last active October 13, 2021 20:35
Rails Cheffile + Vagrantfile
# encoding: utf-8
site 'http://community.opscode.com/api/v1'
cookbook "apt"
cookbook "ruby_build", {:github=>"fnichol/chef-ruby_build", :ref=>"v0.7.2"}
cookbook "rbenv", {:github=>"fnichol/chef-rbenv"}
cookbook "git", {}
cookbook "redis", {:github=>"ctrabold/chef-redis"}
cookbook "postgresql", {:github => 'phlipper/chef-postgresql'}