Skip to content

Instantly share code, notes, and snippets.

View josiah14's full-sized avatar

Josiah josiah14

  • 47 Degrees
  • Remote
View GitHub Profile
@josiah14
josiah14 / typesafe-activator-install.md
Last active August 29, 2015 14:18
Install Typesafe Activator, Scala, SBT, etc.
  1. Download Typesafe activator from the main website (URL not provided because it may change and is easy to find on Google).

  2. mkdir ~/lib && mkdir ~/lib/activator

  3. cd ~/Downloads

    unzip typesafe-activator-1.3.2.zip -d ~/lib/activator

    mv ~/lib/activator/activator-1.3.2 ~/lib/activator/1.3.2

  4. echo 'export PATH=$PATH:~/lib/bin'

mkdir ~/lib/bin

@josiah14
josiah14 / new-leiningen.txt
Last active August 29, 2015 14:18
Create new Leiningen project
1. Use the official Leiningen documentation for installation. It is good enough to not warrant further documentation here.
2. Refer to https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md#tutorial for creating new projects. This documentation is also good enough.
@josiah14
josiah14 / permutation.py
Created April 24, 2015 22:02
permutation_unordered_non-duplicate.py
def inverse_natural_sum(num, start):
for i in range(start, 0, -1):
num = num - i
if num == 0: return i
if num < 0: raise ValueError("number is not a natural sum.")
def permutations_unordered_no_repeat(collection):
def reducer(acc, x):
if acc == collection[0]:
return [ (acc, y) for y in collection[1:] ] + [ (x, y) for y in collection[2:] ]
@josiah14
josiah14 / reverse_string.rb
Last active August 29, 2015 14:20
reverse_string
def reverse_str(str)
str.split('').tap do |str_ary|
len = str_ary.length
(0..len / 2).each do
left = i
right = len - i - 1
str_ary[left], str_ary[right] = str_ary[right], str_ary[left]
end
str_ary.reduce(:+)
end
@josiah14
josiah14 / reverse_string.hs
Created April 30, 2015 19:55
reverse string haskell
-- s is the original string. I recursively call reverse_s on the end of that string until there is nothing left in the string, in
-- which case, I just return the string (providing my edge case that ends the recursion so that I don't end up with infinite recusion).
-- I then prepend each result to the first character of each intermidate string in the recursion until my string has been fully
-- reversed.
reverse_s s = case s of "" -> s
c:cs -> reverse_s cs ++ [c]
-- or you could make it even shorter...
-- foldl is the same as reduce, the part in the parenthesis is a lambda function that takes 2 parameters, an accumulation of the
-- computet result so far, and the current character of the string the calculation is working on.
@josiah14
josiah14 / osx-install-and-proxy.md
Last active June 13, 2016 10:01
OSX Installation and Proxy configuration

The setup for getting docker working on OSX behind a proxy is slightly more complex than just following the instructions on the Docker website. I found the information I needed at the below 2 links, but I'm copying the information here in case for some reason those links break or go away.

For Docker 1.4.1

Missing from the official install guide at the time of writing

First, install Docker normally according to the website: https://docs.docker.com/installation/mac/

Open up your ~/.bashrc or ~/.zshrc (depending on which shell you're using) and add the Docker environment variables by adding the following lines to the file:

@josiah14
josiah14 / defer.go
Created September 9, 2015 19:39
interesting defer behavour
package main
import "fmt"
func main() {
defer fmt.Println("world")
defer fmt.Println("dude")
defer println("sweet")
fmt.Println("hello")
@josiah14
josiah14 / issues.md
Last active October 29, 2017 20:48
Problems encountered when compiling Hadoop ecosystem libraries.

HDFS

  • Need libprotoc 2.5.0 exactly, not compatible with newer systems (mine is running 2.6.1, which is causing a compile error).
    • FIX: Do the following steps
      wget https://github.com/google/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.gz
      tar -xzf protobuf-2.5.0.tar.gz
      cd protobuf-2.5.0
      ./configure
      

make

@josiah14
josiah14 / functional_dependency_injection.py
Created December 20, 2018 22:54
Functional Dependency Injection In Python (Inspired by the Reader Monad)
class Reader(object):
pass
def to_camel_case(snake_str):
parts = snake_str.split('_')
return parts[0] + ''.join([s.capitalize() for s in parts[1:]])
def strip_leading_underscores(string):
if string.startswith('_'):
string = string[1:]