Skip to content

Instantly share code, notes, and snippets.

# FizzBuzz is a classic programming exercise.
#
# The usual example asks the developer to write a program which prints out each number from 1 to 100. But for multiples of 3
# print 'Fizz' instead of the number and for multiples of 5 print 'Buzz'. For numbers which are multiples of both 3 and 5 print
# 'FizzBuzz'.
def fizzbuzz():
for n in range(1,101):
if n%3 == 0 and n%5 == 0: print "fizzbuzz"
else:
@skilbjo
skilbjo / json-csv
Created August 4, 2013 19:30
Convert JSON to CSV using Python
http://garysieling.com/blog/converting-json-to-a-csv-file-with-python
Ideally we want selections from these as a CSV for manual review, and import into mapping software. First, we load a list of files:
import os
folder = 'G:\\maps\\churches\\db.tar\\db\\db'
files = []
for root, dirs, f in os.walk(folder):
@skilbjo
skilbjo / brew doctor
Created January 29, 2014 08:10
Fix brew doctor
## guide for mavericks 10.9 configuration + python development environment setup
http://hackercodex.com/guide/mac-osx-mavericks-10.9-configuration/
http://hackercodex.com/guide/python-development-environment-on-mac-osx/
## installing xcode command line tools
xcode-select --install
## installing homebrew
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"
brew doctor
@skilbjo
skilbjo / primes.js
Created May 15, 2016 04:40
Prime number generator from scratch! :)
var range = [490,510],
start = range[0],
end = range[1]
;
var check_prime = function(num, j, ans){
if(j === 1) return ans;
if(num % j === 0) {
ans.push(false);
@skilbjo
skilbjo / tic-tac-toe.js
Created May 15, 2016 23:08
tic tac toe
var
prompt = require('prompt'),
matrix = [],
o = 'o',
x = 'x',
round = 0
;
// initialize the matrix
for (var i = 0; i <= 2; i++){
@skilbjo
skilbjo / fibonacci-profiling.js
Last active May 19, 2016 02:32
Programming paradigms implementing the fibonacci sequence
// Recursive => Funcational, yay! But dat runtime doe.. :(
var recursive_fib = function(n){
if(n<=1) return n;
return recursive_fib(n-2) + recursive_fib(n-1);
};
// Recursive w/ memoization (caching) => Funcational + performant!
var recursive_memo_fib = function(n){
var f = function(n,cache){
if( cache[n] ) {
@skilbjo
skilbjo / fibonacci.js
Created May 19, 2016 02:33
Fibonacci sequences & profiling!
// Recursive => Funcational, yay! But dat runtime doe.. :(
var recursive_fib = function(n){
if(n<=1) return n;
return recursive_fib(n-2) + recursive_fib(n-1);
};
// Recursive w/ memoization (caching) => Funcational + performant!
var recursive_memo_fib = function(n){
var f = function(n,cache){
if( cache[n] ) {
@skilbjo
skilbjo / spiral.js
Created May 23, 2016 20:19
write a function to draw a spiral
var mark = '*',
n = 25,
create_arr = function(n){
var arr = [];
for(var row=0; row < n; row++){
var line = [];
for(var field=0; field < n; field++){
line.push(' ');
}
arr.push(line);
nohup make -j 4 V=0 </dev/null >/dev/null 2>&1 &
mount /dev/sdb1 usb-drive
sudo mount -o bind ~/usb-drive/tmp /tmp
_python2_ver_major=$(pacman -Qi python2|gawk '$1~/Version/{split($3,v,".");print v[1] "." v[2]}') \
LIBS='-lprotobuf -lglog' && \

Keybase proof

I hereby claim:

  • I am skilbjo on github.
  • I am skilbjo (https://keybase.io/skilbjo) on keybase.
  • I have a public key ASAUJee-HKey3vwxRxk-zWrL9uB7MJ_2Or77tBr_Z2Vqygo

To claim this, I am signing this object: