View Simple clojure play
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 ellipsize [length text] | |
(let [words (take length (split #"\W+" text))] | |
(str (join " " words ) "..."))) | |
(defn indexed [coll] (map vector (iterate inc 0) coll)) | |
(defn index-filter [pred coll] | |
(when pred | |
(for [[idx elt] (indexed coll) :when (pred elt)] idx))) | |
(defn index-of-any [pred coll] | |
(first (index-filter pred coll))) |
View predicates.clj
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 com.jstaten.predicates) | |
(defn non-blank? [line] | |
(re-find #"\S" line)) | |
(defn non-svn? [file] | |
(not (.contains (.toString file) ".svn"))) | |
(defn clojure-source? [file] | |
(.endsWith (.toString file) ".clj")) | |
(use '[clojure.contrib.io :only (reader)]) | |
(defn clojure-loc [dir] |
View lazy.clj
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 stack-eating-fibo [n] | |
(cond | |
(= n 0) 0 | |
(= n 1) 1 | |
:else (+ (stack-eating-fibo (- n 1)) | |
(stack-eating-fibo (- n 2))))) | |
(defn tail-fibo [n] | |
(letfn [(fib | |
[current next n] |
View AnonMap.cs
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
//Anonymous Mapper | |
//Map any object to an anonymous type | |
public static T AnonMap<T>(this object source, T anonType) | |
{ | |
var sourceType = source.GetType(); | |
var destinationType = typeof(T); | |
if (!destinationType.Name.StartsWith("<>")) | |
throw new ArgumentException("Destination type must be anonymous", "anonType"); | |
var ctor = destinationType.GetConstructors().First(); |
View gist:360495
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
using System; | |
using System.Net; | |
using System.Threading; | |
internal class Program | |
{ | |
private static void Main(string[] args) | |
{ | |
Random random = new Random(); |
View DynamicServiceAgent.cs
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
using System; | |
using System.Collections.Generic; | |
using System.Dynamic; | |
using System.Linq; | |
using System.Reflection; | |
using Autofac; | |
//Proof of Concept for a Service Agent implementation using dynamic | |
namespace ActionContainer |
View gist:417372
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
syntax on | |
colorscheme wombat | |
filetype plugin indent on | |
set nocompatible " We don't want vi compatibility. | |
map th :tabfirst<CR> | |
map tj :tabnext<CR> | |
map tk :tabprev<CR> | |
map tl :tablast<CR> |
View DynamicHtml.cs
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
using System; | |
using System.Collections.Generic; | |
using System.Dynamic; | |
using System.Linq; | |
using System.Text; | |
namespace CSharpFourScratch | |
{ | |
internal class Program | |
{ |
View jade.vim
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
" Vim syntax file | |
" Language: Jade | |
" Filenames: *.jade | |
" Ported from tvim-haml - https://github.com/tpope/vim-haml | |
" For use with Jade - http://jade-lang.com/ | |
" Now maintained at: https://github.com/statianzo/vim-jade | |
if exists("b:current_syntax") | |
finish | |
endif |
View .zshrc
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
#Color table from: http://www.understudy.net/custom.html | |
fg_black=%{$'\e[0;30m'%} | |
fg_red=%{$'\e[0;31m'%} | |
fg_green=%{$'\e[0;32m'%} | |
fg_brown=%{$'\e[0;33m'%} | |
fg_blue=%{$'\e[0;34m'%} | |
fg_purple=%{$'\e[0;35m'%} | |
fg_cyan=%{$'\e[0;36m'%} | |
fg_lgray=%{$'\e[0;37m'%} | |
fg_dgray=%{$'\e[1;30m'%} |
OlderNewer