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 = {
@eatonphil
eatonphil / functions.c
Last active May 15, 2024 02:12
Introduction to "Fun" C (using GCC)
/**
* This are a collection of examples for C 201.
* These combine concepts you may or may not be
* familiar with and are especially useful for
* students new to C. There is a lot of really
* cool stuff you can do in C without any cool
* languages.
*
* This is file in particular is an introduction
* to fun function usage in C.
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 / gist:7d57257f65673b343441
Created May 5, 2015 11:47
Bot Dumps Beautiful Uncompiled Spam On My Blog
{
{I have|I’ve} been {surfing|browsing} online more than {three|3|2|4} hours today, yet
I never found any interesting article like yours. {It’s|It is}
pretty worth enough for me. {In my opinion|Personally|In my view},
if all {webmasters|site owners|website owners|web owners} and bloggers made good content as you did, the {internet|net|web} will be {much more|a lot more} useful than ever before.|
I {couldn’t|could not} {resist|refrain from} commenting.
{Very well|Perfectly|Well|Exceptionally well} written!|
{I will|I’ll} {right away|immediately} {take hold of|grab|clutch|grasp|seize|snatch} your {rss|rss feed} as I {can not|can’t} {in finding|find|to find} your {email|e-mail} subscription {link|hyperlink} or {newsletter|e-newsletter} service.
Do {you have|you’ve} any? {Please|Kindly} {allow|permit|let} me {realize|recognize|understand|recognise|know} {so that|in order that} I {may
just|may|could} subscribe. Thanks.|
@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 / server.ml
Last active April 20, 2024 10:42
A simple threaded web server in SML
(*
* Tested on PolyML. `polyc server.ml && ./a.out`
*)
fun println s =
(print (s ^ "\n"); TextIO.flushOut TextIO.stdOut)
fun readAll conn req =
let val ntoread = Socket.Ctl.getNREAD conn in
if ntoread > 0