Skip to content

Instantly share code, notes, and snippets.

View prayagupa's full-sized avatar
💭
Neta

Prayag prayagupa

💭
Neta
View GitHub Profile
@saratpediredla
saratpediredla / hg-fixx-post-commit-hook
Created May 1, 2009 21:16
Mercurial Post Commit Hook for fixx
#!/usr/bin/env ruby
# Created by Sarat Pediredla
# Partner
# hedgehog lab
#
# NOTE: THIS SCRIPT IT TAILORED TO WORKING WITH MERCURIAL AND FIXX VERSION 1.7
#
# INSTALLATION INSTRUCTIONS :
#
;; this file is a walkthrough of Moustache features, a web framework for Clojure
;; http://github.com/cgrand/moustache/tree/master
;; Moustache allows to declare routes, apply middlewares and dispatch on http methods.
;; Moustache is compatible with all frameworks built on Ring, including Compojure
(ns demo
(:use net.cgrand.moustache)
(:use [ring.adapter.jetty :only [run-jetty]])) ;; hmmm Ring without servlets
@ArtemGr
ArtemGr / alternative, using regex
Created May 21, 2009 16:29
CSV parser in Scala
val pattern = java.util.regex.Pattern.compile ("""(?xs) ("(.*?)"|) ; ("(.*?)"|) (?: \r?\n | \z ) """)
val matcher = pattern.matcher (input)
while (matcher.find) {
val col1 = matcher.group (2)
val col2 = matcher.group (4)
// ...
}
@Lytol
Lytol / selection_sort.scala
Created November 4, 2009 06:45
Selection sort implementation in Scala
// Inmperative version
//
def selectionSort(list: Array[Int]): Unit {
def swap(list: Array[Int], i: Int, j: Int) {
var tmp = list(i)
list(i) = list(j)
list(j) = tmp
}
var i = 0
#!/usr/bin/env ruby
require 'rubygems'
require 'net/http'
require 'json'
http = Net::HTTP.new('stream.twitter.com', 80)
get = Net::HTTP::Get.new("/1/statuses/filter.json?track=awesome")
get.basic_auth ARGV[0], ARGV[1]
(ns net.experimentalworks.clojure.comp
(:use compojure))
(defroutes helloworld-routes
(GET "/login/:user"
[(session-assoc :loggedin (:user params))
(html [:html [:body [:p "You are now logged in as " (:user params)]]])])
(GET "/*"
(if (contains? session :loggedin)
(html [:html [:body [:p "Welcome back " [:b (:loggedin session)]]]])
(defn set-log4j-level! [level]
"Sets the log4j root logger's level."
(let [root-logger (org.apache.log4j.Logger/getRootLogger)]
(.setLevel root-logger level)))
(defn set-log4j-to-debug!
[]
(set-log4j-level! org.apache.log4j.Level/DEBUG))
(defn set-log4j-to-info!
@timcharper
timcharper / lein-completion.bash
Created April 15, 2010 18:06
bash completion for leiningen
_lein_test()
{
local curw
COMPREPLY=()
curw=${COMP_WORDS[COMP_CWORD]}
if [ -d test ]; then
COMPREPLY=($(compgen -W '$(cd test; find * -name \*.clj | sed "s/.clj\$//" | sed "s/_/-/g" | sed "s|/|.|g")' -- $curw));
return 0
fi
}
@dahnielson
dahnielson / UUID.php
Last active May 31, 2024 23:54
Pure PHP UUID generator
<?php
/**
* UUID class
*
* The following class generates VALID RFC 4122 COMPLIANT
* Universally Unique IDentifiers (UUID) version 3, 4 and 5.
*
* UUIDs generated validates using OSSP UUID Tool, and output
* for named-based UUIDs are exactly the same. This is a pure
* PHP implementation.
@takumikinjo
takumikinjo / .gitignore
Created August 5, 2010 13:56
HTML5 Presentation export for Org-mode
README.html