Skip to content

Instantly share code, notes, and snippets.

View yurrriq's full-sized avatar
🙈
I may be slow to respond.

Eric Bailey yurrriq

🙈
I may be slow to respond.
View GitHub Profile
@ngerakines
ngerakines / memoize.erl
Created September 27, 2008 17:55
A small module to provide memoize functions in Erlang.
%% Copyright (c) 2008 Nick Gerakines <nick@gerakines.net>
%%
%% Permission is hereby granted, free of charge, to any person
%% obtaining a copy of this software and associated documentation
%% files (the "Software"), to deal in the Software without
%% restriction, including without limitation the rights to use,
%% copy, modify, merge, publish, distribute, sublicense, and/or sell
%% copies of the Software, and to permit persons to whom the
%% Software is furnished to do so, subject to the following
%% conditions:
/**
* A `tail -f` implementation in Node.js.
*
* Bratish Goswami
* bratishgoswami AT gmail DOT com
*
*/
var sys = require("sys"),
fs = require('fs'),
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@sunilnandihalli
sunilnandihalli / curry.clj
Created December 17, 2010 20:33
a macro to create fixed-arity curryable function in clojure
(defmacro def-curry-fn [name args & body]
{:pre [(not-any? #{'&} args)]}
(if (empty? args)
`(defn ~name ~args ~@body)
(let [rec-funcs (reduce (fn [l v]
`(letfn [(helper#
([] helper#)
([x#] (let [~v x#] ~l))
([x# & rest#] (let [~v x#]
(apply (helper# x#) rest#))))]
@rlm
rlm / gist:746185
Created December 18, 2010 05:19
curry.clj
(ns sunil.curry)
(defn partial+
"Takes a function f and fewer than the normal arguments to f, and
returns a fn that takes a variable number of additional args. When
called, the returned function calls f with args + additional args.
differs from the core version in that it works on just one argument."
{:added "1.0"}
([f] f)
([f arg1]
@tszming
tszming / objc.cfg
Created April 25, 2011 18:39
My uncrustify config file for objective-c
#
# uncrustify config file for objective-c and objective-c++
#
indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs
output_tab_size = 4 # new tab size
indent_columns = output_tab_size
indent_label = 2 # pos: absolute col, neg: relative column
indent_align_assign = FALSE
@amtal
amtal / life_sync_cell.lfe.clj
Created May 30, 2011 10:08
Conway's Life in Lisp Flavored Erlang...
;;; Global clock implementation of Life.
(defmodule life_sync_cell
(export (start_link 1) (set_neighbours 2) (tick 1)
(init 1) (handle_cast 2))
(using gen_server)
(behaviour gen_server))
(include-file "deps/lfe_utils/include/using.lfe")
;;; Exported:
(ns one-lineres)
;; 1. Multiple Each Item in a List by 2
(map #(* 2 %) (range 1 11))
;; 2. Sum a List of Numbers
(reduce + (range 1 1001))
;; 3. Verify if Exists in a String
(def words #{"scala" "akka" "play framework" "sbt" "typesafe"})
@heisters
heisters / Solarized High Contrast Dark.itermcolors
Created June 8, 2011 21:49
Solarized High Contrast Dark theme for iTerm2
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.19370138645172119</real>
<key>Green Component</key>
<real>0.15575926005840302</real>
@gdamjan
gdamjan / proplist_to_record.hrl
Created September 13, 2011 12:41
Erlang macro to create proplist_to_record functions
%%% This is a clever Erlang macro that given a record name will create a new function
%%% that converts from a property list to the record (which really is a taged tuple).
-define(proplist_to_record(Record),
fun(Proplist) ->
Fields = record_info(fields, Record),
[Tag| Values] = tuple_to_list(#Record{}),
Defaults = lists:zip(Fields, Values),
L = lists:map(fun ({K,V}) -> proplists:get_value(K, Proplist, V) end, Defaults),
list_to_tuple([Tag|L])