Skip to content

Instantly share code, notes, and snippets.

View tebeka's full-sized avatar
💭
alive

Miki Tebeka tebeka

💭
alive
View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>
#include <gc/gc.h>
mpz_t *
fact(unsigned n)
{
mpz_t *res;
#!/usr/bin/env gsi-script
(define (fact n)
(let loop ((n n) (r 1))
(if (< n 2)
r
(loop (- n 1) (* r n)))))
(if (not (= (length (command-line)) 2))
(println "usage: fact1.scm NUMBER")
#!/usr/bin/env python
def fact(n):
r = 1
while n > 1:
r *= n
n -= 1
return r
from sys import argv
#!/usr/bin/env clojure
; vim:ft=clojure
(defn fact [n]
(loop [n n f 1]
(if (= n 1)
f
(recur (dec n) (* f n)))))
(if (not= (count *command-line-args*) 1)
_gitsync() {
if [ $# -eq 1 ]; then
repo=origin
else
repo=$2
fi
branch=$(git branch --no-color | grep '^*' | awk '{print $2}')
if [ -z "$branch" ]; then
# git will show an appropriate error
return 1
user=> (use '[clojure.java.io :only (reader)])
nil
user=> (spit "/tmp/blah" "blah blah")
nil
user=> (slurp (reader "/tmp/blah"))
"blah blah"
user=>
(use '[clojure.set :only (union)])
(def *count* (atom 10))
(defn get-entries []
(let [n (swap! *count* inc)]
(map (fn [i] {:id i :title (str "title " i)}) (range n))))
(defn process-entry [entry]
(println (:title entry)))
user = users.get_current_user()
if not user:
raise HTTPRedirect(users.create_login_url(cherrypy.request.path_info)))
@tebeka
tebeka / gist:788685
Created January 20, 2011 21:14
Iterate over a directory
(import 'java.io.File)
(require '[clojure.zip :as zip])
(defn branch? [f]
(.isDirectory f))
(defn children [f]
(.listFiles f))
(defn iterzip [z]
package com.adconion.ntdw.util;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import com.adconion.AbstractDatabaseTest;
@Test(groups = "functest", sequential = true)
public class NamedQueriesTest extends AbstractDatabaseTest {
@DataProvider(name = "beans")