This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;dddd | |
(ns package_manager | |
(:use [clojure.string :only [split, lower-case]])) | |
(def system (atom {})) | |
(def installed (atom (sorted-set))) | |
(def running (atom true)) | |
(defn in? [coll elm] | |
(some #{elm} coll)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns circuits.core) | |
(defn wire | |
"This is a wire. It takes an optional delay | |
keyword parameter and outputs a map with :i, and :o | |
which are atoms and :d which represents the delay | |
in milliseconds. The default delay is 0. When i changes value, | |
o follows in d number of seconds" | |
[& {:keys [del] :or {del 0}}] | |
(let [in (atom 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#If the integers from 1 to 999,999,999 are written as words, sorted alphabetically, and concatenated, what is the 51 billionth letter? | |
#where strings have no spaces | |
import time | |
singles = ["", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"] | |
singles.sort() | |
teens = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", | |
"seventeen", "eighteen", "nineteen"] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" File: clojure.vim (conceal enhancement) | |
" Author: Jeb Beich (jebbeich@gmail.com) | |
" Last Change: 2013-05-24 | |
" Version: 1.0.0 | |
" Require: | |
" set nocompatible | |
" somewhere on your .vimrc | |
" Vim 7.3 or Vim compiled with conceal patch. | |
if !has('conceal') || &enc != 'utf-8' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns foo.auth.core | |
(:require [cemerick.friend :as friend] | |
[cemerick.friend.util :refer [gets]] | |
[cemerick.friend.workflows :as workflow] | |
[cemerick.friend.credentials :as creds] | |
[tickets.routes.user :refer [login-friend]] | |
[ring.util.request :as req] | |
[noir.response])) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import copy | |
import functools | |
def memoize(obj): | |
cache = obj.cache = {} | |
@functools.wraps(obj) | |
def memoizer(*args, **kwargs): | |
key = str(args) + str(kwargs) | |
if key not in cache: | |
cache[key] = obj(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
timi-$: curl -v --data "username=tom@gmail.com&password=password" localhost:3000/registration | |
* Adding handle: conn: 0x7fe4c9036400 | |
* Adding handle: send: 0 | |
* Adding handle: recv: 0 | |
* Curl_addHandleToPipeline: length: 1 | |
* - Conn 0 (0x7fe4c9036400) send_pipe: 1, recv_pipe: 0 | |
* About to connect() to localhost port 3000 (#0) | |
* Trying ::1... | |
* Connected to localhost (::1) port 3000 (#0) | |
> POST /registration HTTP/1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import namedtuple | |
enum = namedtuple('Operations', ['add', 'subtract', 'multiply', 'divide']) | |
operations = enum(add='+', subtract="-", multiply="*", divide="/") | |
class Relation: | |
def __init__(self, a, b, op): | |
self.a = a | |
self.b = b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def memoize(func): | |
cache = {} | |
def memo(string): | |
if not string in cache: | |
cache[string] = func(string) | |
return cache[string] | |
return memo | |
@memoize | |
def permutations(string): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def character_frequency(words): | |
words = words.upper().split(' ') | |
counts = [0] * 26 | |
for word in words: | |
for char in word: | |
counts[ord(char) - ord('A')] += 1 | |
letters = [chr(x+ord('A')) for x in range(26)] | |
return sorted(zip(counts, letters))[-1: -11: -1] |
OlderNewer