Skip to content

Instantly share code, notes, and snippets.

View igstan's full-sized avatar

Ionuț G. Stan igstan

View GitHub Profile
// BNF parser framework for JavaScript
// Oleg Andreev
var result = (function(text){
// The Y Combinator
var Y=function (gen) {
return function(f) {return f(f)}(
function(f) {
return gen(function() {return f(f).apply(null, arguments)})})}
/*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*/
(function(){
var UPC_SET = {
"3211": '0',
"2221": '1',
"2122": '2',
// The `quickEach` method will pass a non-unique jQuery instance
// to the callback meaning that there will be no need to instantiate
// a fresh jQuery instance on each iteration. Most of the slow-down
// inherent in jQuery's native iterator method (`each`) is the constant
// need to have access to jQuery's methods, and so most developers
// see constructing multiple instances as no issue... E.g.
// $(...).each(function(){ $(this)... $(this)... $(this)... });
// A better approach would be `quickEach`.
jQuery.fn.quickEach = (function(){
@igstan
igstan / centered_triangle.html
Created May 3, 2011 13:47 — forked from romannurik/centered_triangle.html
A simple CSS trick to create a horizontally- or vertically-centered 'selected' callout triangle using zero images.
<!DOCTYPE html>
<html>
<head>
<style>
body {
margin: 40px;
}
a {
display: inline-block;
@igstan
igstan / hack.sh
Created August 22, 2012 20:08 — forked from DAddYE/hack.sh
OSX For Hackers
#!/bin/sh
##
# This is a script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# Run in interactive mode with:
# $ sh -c "$(curl -sL https://raw.github.com/gist/2108403/hack.sh)"
#
# or run it without prompt questions:
@igstan
igstan / DateUtils.scala
Created December 4, 2012 08:50 — forked from fcroiseaux/DateUtils.scala
Utils class to calculate and work with holidays in a country (here in Luxembourg)
package utils
import org.joda.time.{Period, LocalDate}
object DateUtils {
def dateRange(from: LocalDate, to: LocalDate, step: Period): Iterator[LocalDate] =
Iterator.iterate(from) {
dt => dt.plus(step)
}.takeWhile(!_.isAfter(to))
@igstan
igstan / curried.rkt
Created December 25, 2012 00:13 — forked from anonymous/curried.rkt
Shorthand notation for curried functions in Racket.
#lang racket
(define ((add x) y)
(+ x y))
;; ((add 1) 2) -> 3
;; (add 1 2) -> arity mismatch error
package deiko
import scala.concurrent.Future
import scala.concurrent.duration.Duration
import scalaz.concurrent.Task
import scalaz.stream._
import play.api.libs.iteratee._
import Process._
object Conversion {
@igstan
igstan / wasps.md
Last active December 25, 2015 21:39 — forked from aphyr/gist:7044081

schema

It's actually more like a figure-eight cycle, though--depending on species. Wasps start out in the syconium full of male flowers, called a caprifig. The male wasps mate with the females immediately after pupation, and fertilize still incomplete female wasps. They dig a tunnel out of the caprifig then die; the female wasps escape via the tunnel, carrying male-flower pollen with them.

Female wasps then enter either caprifigs or figs--male or female syconia. If they enter a male syconium, they get to lay their eggs in the male flowers and the process starts anew. If they enter a female syconium, they can't lay eggs in the female flowers because they're shaped wrong, and die alone--but not before coating the female flowers in the male pollen from their birthplace.

The female syconium, if fertilized by wasps, develops seeds, is eaten, and gives rise to the next generation of fig trees. The syconium secretes digestive enzymes

---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.