Skip to content

Instantly share code, notes, and snippets.

@hamiltondanielb
hamiltondanielb / dev_setup.sh
Last active August 29, 2015 14:06
Dev Setup
#!/bin/bash
echo 'Running Dev setup'
if [ "$(uname)" == "Darwin" ]; then
# Do something under Mac OS X platform
textMessage="--- OSX setup Summary ---\n"
if which xcode-select >/dev/null; then
textMessage=$textMessage"--not installing xcode-select, already installed \n"
else
textMessage=$textMessage"--installing xcode-select\n"
sudo xcode-select --install
<!DOCTYPE html>
<html>
<head>
<title>Decoding Morse Code With JavaScript</title>
<style type="text/css">
div.output {}
div.output p.message {
//Knapsack algorithm
//==================
// wikipedia: [Knapsack (0/1)](http://en.wikipedia.org/wiki/Knapsack_problem#0.2F1_Knapsack_Problem)
// Given a set `[{weight:Number, benefit:Number}]` and a capacity,
// find the maximum value possible while keeping the weight below
// or equal to the capacity
// **params**:
// `capacity` : Number,
// `items` : [{w:Number, b:Number}]
// **returns**:
@hamiltondanielb
hamiltondanielb / gist:5aad59711ebc6dd1c39f
Created June 18, 2014 17:11
Self Describing numbers
filename = ARGV[0]
file = File.new(filename, "r")
while (line = file.gets)
array = line.scan(/./)
new_array = Array.new
array.length.times do |var|
new_array << array.count(var.to_s).to_s
end
if new_array.eql? array