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
# -*- coding: utf-8 | |
import random | |
class APIHandler(object): | |
def __init__(self): | |
self.queue = list() | |
def do_api_request(self, *args, **kwargs): | |
# tässä koko kupletin juoni. työnnetään paikallisesti määritelty |
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 functools import wraps | |
def db(selector): | |
def _funcall(function): | |
@wraps(function) | |
def _wrapper(row): | |
got_args = { | |
'primary': { '1': ('baba', 15), '2': ('gaga', 16) }, | |
'secondary': { '1': ('foo', 17), '2': ('bar', 18) }, | |
} |
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
(defn multiple-of [number divisor] (and (not (= number divisor)) | |
(= (mod number divisor) 0))) | |
(defn not-multiples-or-1 [numbers divisor] | |
(filter (fn [n] | |
(and | |
(not (= n 1)) | |
(not (multiple-of n divisor)))) numbers)) | |
(defn primes-in-decreasing-seq [n] (reduce not-multiples-or-1 n (range 2 (Math/sqrt (first n))))) |
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
(defmacro play-chord | |
[ts notes] | |
(let [note-on (map #(list 'sampled-piano %) (eval notes))] | |
`(at ~ts ~@note-on))) | |
(play-chord (+ 1000 (now)) (chord :A4 :major7)) | |
; expands to | |
(overtone.live/at | |
(+ 1000 (now)) |
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
(use 'quil.core) | |
(def draw-state (atom :draw)) | |
(defn setup [] | |
(background 11 11 11) | |
(smooth)) | |
(defn my-random [min max] | |
(let [delta (- max min)] |
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
/* | |
The most trivial implementation of what I need. Introduces code | |
duplication and can become a hassle to maintain if more and more | |
data sources are introduced. | |
What would be the best approach to keep the code organization as | |
simple as possible but on the other hand keep the clarity of this | |
two data source example? | |
When should a programmer "feel the pain" of code duplication? |
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 megakolmio.core | |
(:gen-class)) | |
(defn match-side? | |
"Check if given sides match each other" | |
[s1 s2] | |
(case s1 | |
:fox-bottom (= s2 :fox-top) | |
:deer-bottom (= s2 :deer-top) | |
:racoon-bottom (= s2 :racoon-top) |
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
void setup() | |
{ | |
size(1000, 500); | |
verts = new ArrayList<Vertex>(); | |
for(int i=0;i<50;i++) { | |
verts.add(new Vertex(random(75, 150))); | |
} | |
background(bg); | |
} |
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
# -*- encoding: utf-8 -*- | |
from BeautifulSoup import BeautifulSoup | |
from random import sample, choice | |
import httplib2 | |
import sys | |
import pickle | |
import os.path | |
class Quotes(object): |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
typedef struct buffer_t { | |
void *data; | |
int length; | |
struct buffer_t* next; | |
struct buffer_t* prev; |