Skip to content

Instantly share code, notes, and snippets.

@calebsmith
calebsmith / gist:750d599bb811913999e9
Created February 6, 2015 14:01
Playing with SKI and Y combinators in Erlang
-module(funs).
%%% SKI combinators
i(X) -> X.
k(X) ->
fun(F) -> X end.
s(F) ->
fun(G) ->
OViiiiiiVViii***:****::*********iiiiiiiiiiiVVViiViiiVVViVViVVVVVVVVVVVVVVVVVVVVV
iiiVViiiiiiii***:****:****i*****iiiiiiiiViiiiViViVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
iiiiViiiiiiii********::*:********iiiiiiiiiiiVViiVVVVVVVVVVVVVVVVVVVVVVViiiiiiiVV
iiiiiiiiiiiii********:::*******i***iiiiiiiiiViVVVVVViVVVVViiiiiiiiiiiiiiiiiiiiiV
ii*iiiiiiiiii*VV*****::*:::*****VEEEEOViiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
ii*iiiiiiiiiiii*****:::*:***VEOEEMMEMMEEEEViiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
VViiiiiiiiiiiii****:::::::*EOEEEEEEEEEEOEEEEiiiiiiiiiiiiiiiiiiiiiiiiiiiii*iiiiii
iiiiiiiiiiii*i*****::::::*OEEEEEEOVOEOEVVEEEMiiiiiiiiiiiiiii*iiiiii*ii*iiiiiiiii
iiiiiiiiiiiiiiii***::::::OEEEOOVOi~:*i:::iEEiOiiiiii*********iiiiiiiiii*ii*iiiii
iiiiiiiiiiiiii****:::::::OEME**::::~::***:VEVOi*i****i*******iii*iiiii**ii*iiiii
@calebsmith
calebsmith / gist:98697ccc5ad81c103b1c
Created March 23, 2015 17:49
Django Sports App Project Steps
1. Project structure ( mkvirtualenv, startproject, startapp)
2. commit
3. Models - makemigrations, migrate
4. Admin
5. Enter in example data.
6. Views, Urls, a skeleton of templates. (extends base.html)
7. Commit
8. Templates (focus on variables)
9. Commit
@calebsmith
calebsmith / gist:d523cce86e6f68413835
Created April 6, 2015 17:13
Some thoughts on sports App project and final project
Overall thoughts from sportsApp project:
Get the data model down before moving on.
Determine which views need what parameters. (Which ones take a pk? To what model?)
If it works, commit and push up.
For the final project:
1. Brainstorm ideas and decide on a good project.
What is the simplest thing that could possibly work?
Clone another's repo, branch and merge
#Ask to be made a "contributor" so you can commit directly to their repo
git clone [email protected]:calebsmith/fn.py.git
# Can work as normal on the master branch, *or* create a branch (if feature/bug fix is mostly orthogonal)
Creating branches
git checkout -b mybranchname
@calebsmith
calebsmith / gist:6498841507de384a2b13
Created June 2, 2015 20:17
Python script for livereload server with fallback to simple server
#!/usr/bin/env python
"""
A server that works with the livereload chrome extension to automatically
refresh the browser whenever a set of files changes. The server degrades to a
SimpleHTTPServer w/o livereload capability if the livereload Python package is
not available.
The default port is 8000. Supply a command line argument for a different port.
This serves files from the current directory on your local browser and is good
@calebsmith
calebsmith / gist:64ae6f483fd110028c04
Last active August 29, 2015 14:23
TriPython - Python for Beginners - Resources
(defn perlin4 [x y z w]
(let [X (bit-and (int x) 255)
Y (bit-and (int y) 255)
Z (bit-and (int z) 255)
W (bit-and (int w) 255)
xx (- x (int x))
yy (- y (int y))
zz (- z (int z))
ww (- w (int w))
(ns xkcd-helper
(:require [clojure.string :as s]
[net.cgrand.enlive-html :as enl]))
(def base-url "https://xkcd.com/")
(def build-url #(str base-url % "/"))
(def fetch-url (comp enl/html-resource #(new java.net.URL %)))
(def fetch-url-on-num (comp fetch-url build-url))
(defn get-transcript [cont]
(ns noise.gen
(:require [ionsails.noise.perlin :as perlin]))
(defn get-range
([width]
(for [x (range width)]
(vector x)))
([width height]
(for [y (range height)
x (range width)]