Skip to content

Instantly share code, notes, and snippets.

(ns interpreter
(:require [clojure.test :refer :all]))
(defn operation_mod_n [operation n]
(fn [& args]
(mod (apply operation args) n)))
(def m+ (operation_mod_n + 1000))
(def m* (operation_mod_n * 1000))
(cua-mode t)
(setq make-backup-files nil)
(setq inhibit-startup-message t)
(setq column-number-mode t)
(show-paren-mode 1)
(setq-default indent-tabs-mode nil)
(when (fboundp 'tool-bar-mode)
(tool-bar-mode -1))
(require 'uniquify)
@zackmdavis
zackmdavis / meetings.sh
Created August 3, 2014 01:56
consecutive meetings counter
echo "<h1>3</h1>" > index.html && python3 -m http.server & firefox localhost:8000
<blockquote>So if you have P_1 that gives x 50% of the time and y the
rest, and P_2 that gives x 40% of the time and y 60% of the time, we
say that the difference is .2: given 100 samples, we will have 80
matching samples and 20 unaccounted for (10 more x samples for P_1,
and 10 less y).</blockquote>
<p>What? Out of a hundred samples, P_1 yields x in 50 of them, and of
these, P_2 matches it with another x 50*0.4 = 20 times. In another 50
samples, P_1 yields y, and P_2 matches it 50*0.6 = 30 times, for a
total of 20 + 30 matching samples. (And it would be the same for any
@zackmdavis
zackmdavis / gist:2a199d63e8b8f25d14b5
Created October 26, 2014 03:27
hilarious error message
zmd@SuddenHeap:~/Code/Finetooth$ git commit --amend
Traceback (most recent call last):
File "./manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
zmd@ExpectedReturn:~/Code/Textbook_Exercises_A/Programming_Challenges$ rustc 5-9-7.rs --test
<std macros>:8:12: 31:67 error: cannot apply unary operator `!` to type `Hardcover`
<std macros>:8 if !$cond {
<std macros>:9 fail!($($arg),+)
<std macros>:10 }
<std macros>:11 );
<std macros>:12 )
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
@zackmdavis
zackmdavis / gist:0fa3e76087570fe5d0f5
Created November 20, 2014 21:51
isnt for Python
http://eli.thegreenplace.net/2010/06/30/python-internals-adding-a-new-statement-to-python/
http://mathamy.com/import-accio-bootstrapping-python-grammar.html
https://hg.python.org/cpython/file/8bc29f5ebeff/Grammar/Grammar
(setq python-debug-line-identifier-counter ?A)
(defun python-print-debug-line ()
(interactive)
(insert "print(\"MY DEBUG MARKER ")
(insert python-debug-line-identifier-counter)
(insert "\", )")
(backward-char 1)
(setq python-debug-line-identifier-counter
(1+ python-debug-line-identifier-counter)))
In [9]: datetime.datetime.now().strftime('%F-%T%z')
Out[9]: '2014-12-18-23:25:42'
In [10]: datetime.datetime.strptime(datetime.datetime.now().strftime('%F-%T%z'), '%F-%T%z')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/deploy/ssman/current/ssman/app/management/commands/shell.pyc in <module>()
----> 1 datetime.datetime.strptime(datetime.datetime.now().strftime('%F-%T%z'), '%F-%T%z')
/usr/lib/python2.7/_strptime.pyc in _strptime(data_string, format)
def condense_meeting_times(meetings)
start_times = meetings.map { |start, _stop| [start, :start] }
stop_times = meetings.map { |_start, stop| [stop, :stop] }
boundaries = start_times + stop_times
boundaries.sort!
meetings_in_session = 0
everyone_is_free = true
shadows = []
current_meeting_shadow = []