Skip to content

Instantly share code, notes, and snippets.

/*
* Original Source: http://darcyclarke.me/development/fix-jquerys-animate-to-allow-auto-values-2/
*
* This is an addition to Darcy Clark's animateAuto function that allows you to animate a div with
* a set max-width/height growing to full height/width. In my use case, I had a div with a height
* larger than its default max-height. I wanted to animate the growth from the set max-height to the
* actual height. This addition to Darcy's function simply turns off the max-height/width and immediately
* sets the actual height of the div to the previous max-height/width. Then it animates to auto like normal.
* Also, the speed variable can optionally be a function of height or width or both.
*/
/*
* Original Source: http://stackoverflow.com/questions/1318076/jquery-hasattr-checking-to-see-if-there-is-an-attribute-on-an-element
*
* jQuery add-on to check if an element has an attribute.
*/
jQuery.fn.hasAttr = function(name) {
return typeof this.attr(name) === typeof undefined || this.attr(name) === false;
};
<?php
/**
* Original Source: http://www.gerbenjacobs.nl/push-new-value-into-array-with-php/
*/
function array_push_insert($array, $index, $value) {
if (array_key_exists($index, $array)) {
$firstArray = array_slice($array, 0, $index);
$lastArray = array_slice($array, $index);
array_push($firstArray, $value);
@eatonphil
eatonphil / py_js_oo.py
Last active August 29, 2015 14:17
Javascript-Style Objects in Python
# After spending too much time away from Python on Javascript, I gave this a shot. To my surprise, it worked!
# Since Python doesn't bind "self" implicitly in classes, this looks pretty similar to Python classes.
# You want inheritance? Pass in the Parent "class" and copy the key/vals a la Javascript.
# Even adding dot syntax is not too tough.
def Cat(legs, colorId, name):
def sayHi():
print 'Hi, my name is %s. I have %s legs and am %s.' % (this['name'], this['legs'], this['color'])
this = {
open OWebl
open Response
open Rule
open Server
let handler =
Handler.create
(StaticRouteRule.create "/" [Verb.GET])
(SimpleResponse.create "Hello World!")
@eatonphil
eatonphil / app.ml
Last active August 29, 2015 14:17
A Custom Response for User-Assigned Headers
open OWebl
open Rule
open Server
open Mycustomresponse
let handler =
Handler.create
(StaticRouteRule.create "/" [Verb.GET])
(MyCustomResponse.create "Hello World!" []) (*headers go here*)
@eatonphil
eatonphil / nginx.conf
Created May 28, 2015 12:10
OWebl Nginx Bare Minimum Config
upstream app {
least_conn;
server localhost:9090;
}
server {
listen 80;
# Uncomment these if you want nginx to serve your static files.
#location ~ \.(png|jpeg|jpg|css|js|ico|ttf|woff) {
@eatonphil
eatonphil / poly-build.ml
Last active January 24, 2016 06:03
Poly/ML specific build tool partially reimplementing the polyc bash script in SML.
(*
* Poly/ML specific build tool partially reimplementing the polyc bash script in SML.
* Additionally, this adds a means to include files needed in the main script.
* Usage:
* $ polyc -o poly-build poly-build.sml # bootstrap the tool
* $ ./poly-build poly-build.sml # compile itself
* $ mv a.out poly-build
* $ ./poly-build a.sml b.sml c.sml # where needs some fun/val from b.sml and c.sml
*)
#! /bin/sh
prefix=/usr/local
exec_prefix=${prefix}
BINDIR=${exec_prefix}/bin
LINK=cc
LIBDIR=${exec_prefix}/lib
LIBS="-lpthread -lm -lgcc_s -lgcc -L/usr/local/lib -lffi "
CFLAGS="-O2 -pipe -fstack-protector -fno-strict-aliasing"
# Extra options for Windows. config.status sets these conditionals to either "" or "#".
structure File = Ponyo.Os.File
structure String = Ponyo.String
structure Format = Ponyo.Format
val f = PolyML.NameSpace.displayTypeExpression
val g = PolyML.globalNameSpace
fun parseModule (path: string) =
let