Skip to content

Instantly share code, notes, and snippets.

@calebsmith
calebsmith / script.sh
Created December 18, 2023 21:39
loading click-ingest with data
kcat -b localhost:29092 -t catchall_legacy -P -l test_events.jsonl
@calebsmith
calebsmith / gist:e30e6e863a575cef1fd9
Created November 10, 2015 02:08
Floyd's Cycle Detection Algorithm
(define (contains-cycle? lst)
(let inner ((a (nil-safe-cdr lst))
(b (nil-safe-cdr (nil-safe-cdr lst))))
(cond ((or (not (pair? a))
(not (pair? b))) #f)
((or (eq? a b)
(eq? a (nil-safe-cdr b))) #t)
(else (inner (nil-safe-cdr a) (nil-safe-cdr (nil-safe-cdr b)))))))
@calebsmith
calebsmith / church.clj
Created October 5, 2015 15:35
Church numbers and pairs in Clojure (WIP)
; This uses only fn and def in Clojure to create non-negative integers and pairs.
; (This restricts the language to only using lambda calculus.)
; Church numerals
(defn succ [n]
(fn [f]
(fn [x]
(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)]
(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]
(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))
@calebsmith
calebsmith / gist:64ae6f483fd110028c04
Last active August 29, 2015 14:23
TriPython - Python for Beginners - Resources
@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
Clone another's repo, branch and merge
#Ask to be made a "contributor" so you can commit directly to their repo
git clone git@github.com: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: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?