Skip to content

Instantly share code, notes, and snippets.

View joshrotenberg's full-sized avatar
💀

josh rotenberg joshrotenberg

💀
View GitHub Profile
@ghoseb
ghoseb / ns-cheatsheet.clj
Last active April 11, 2024 05:28 — forked from alandipert/ns-cheatsheet.clj
Clojure ns syntax cheat-sheet
;;
;; NS CHEATSHEET
;;
;; * :require makes functions available with a namespace prefix
;; and optionally can refer functions to the current ns.
;;
;; * :import refers Java classes to the current namespace.
;;
;; * :refer-clojure affects availability of built-in (clojure.core)
;; functions.
; Released under the Apache License, Version 2.0
; http://www.apache.org/licenses/LICENSE-2.0.html
(defmacro try-let
"A combination of try and let such that exceptions thrown in the binding or
body can be handled by catch clauses in the body, and all bindings are
available to the catch and finally clauses. If an exception is thrown while
evaluating a binding value, it and all subsequent binding values will be nil.
Example:
import sbt._
class HelloworldProject(info: ProjectInfo) extends AppengineProject(info)
@peterc
peterc / jetty
Created May 18, 2010 05:39
/etc/init.d/jetty
#!/usr/bin/env bash
#
# Startup script for jetty under *nix systems (it works under NT/cygwin too).
# To get the service to restart correctly on reboot, uncomment below (3 lines):
# ========================
# chkconfig: 3 99 99
# description: Jetty 7 webserver
# processname: jetty
# ========================
@hdenk
hdenk / build.gradle
Created February 8, 2011 03:37
clojure webapp with http-authentication using ring/moustache, deployable as foo.war
// gradle-build that uses meikel brandmeyers clojure-plugin for gradle (clojuresque)
// see http://bitbucket.org/kotarak/clojuresque
// use a standard maven directory-layout -> /src/main/clojure, /src/main/webapp
apply plugin: 'clojure'
apply plugin: 'war'
apply plugin: 'project-report'
warnOnReflection = false
aotCompile = true // needed for gen-class in servlet.clj
@kfish
kfish / watch-read.hs
Created February 15, 2011 02:01
Haskell inotify example: monitor file modifications
{-# OPTIONS -Wall #-}
module Main where
import Control.Concurrent (threadDelay)
import System.Environment (getArgs)
import System.INotify
main :: IO ()
main = do
@eproxus
eproxus / virus.erl
Created March 4, 2011 09:26
A small module that jumps between connected nodes
%% @doc A small module that jumps between connected nodes.
%% @author Gianfranco Alongi <gianfranco.alongi@gmail.com>
%% @author Adam Lindberg <hello@alind.io>
-module(virus).
-export([start/0]).
-export([start/1]).
start() -> spawn_process(code:get_object_code(?MODULE)).
start(Beam) -> spawn_process(Beam).
@nbogie
nbogie / SimpleAesonJsonExample.hs
Created May 22, 2011 16:19
Simplest Aeson json parsing and generation example
{-# LANGUAGE OverloadedStrings #-}
-- This is a very simple example of parsing and generating json with Aeson,
-- by a haskell newbie and intended for newbies.
--
-- This almost certainly contains a number of bad practices. It works for
-- me and hopefully will get you started.
--
-- I couldn't find a stand-alone example of Aeson usage and found it tricky to
-- get going. For example, if you don't realize to enable the language extension
@dcbriccetti
dcbriccetti / ImplicitTimerDemo.scala
Created July 12, 2011 14:31
Example of using implicit conversions to avoid creating anonymous inner classes
package sample
import java.util.{TimerTask, Timer}
/**
* Shows Java way of creating an anonymous inner class to supply the code for a TimerTask.
*/
object TimerDemo extends Application {
new Timer().schedule(new TimerTask {
def run() {
@enjalot
enjalot / index.html
Created September 8, 2011 15:15
Simple Pie Chart example with D3.js
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Testing Pie Chart</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.1.3"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js?2.1.3"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?2.1.3"></script>
<style type="text/css">