Skip to content

Instantly share code, notes, and snippets.

@lunr
lunr / my.cnf
Created April 27, 2016 15:13
MAMP 3.5 MySQL Configuration to speak UTF-8
# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /Applications/MAMP/db/mysql) or
@lunr
lunr / gradesql.php
Created November 13, 2012 21:40
Grade SQL Selection
$sql = "SELECT * FROM alpha WHERE letter REGEXP '%s' ORDER BY letter DESC;";
$letter = 'LL';
$regex = '^'.$letter.'$|^[A-'.(strlen($letter) > 1 ? substr($letter, -1) : chr(ord(substr($letter, -1)) - 1)).'].?$';
echo sprintf($sql, $regex);
@lunr
lunr / animator.js
Created July 19, 2012 19:03
Animator: JS to animate a set of images in a 360 rotation -- Works on Touchscreen devices too
$(document).ready(function() {
var speedLimit = 4; // higher allows the spin to jump frames faster. More speed.
var sensitivity = 10; // higher numbers makes it *less* sensitive, i.e. get to the speed limit slower.
var dragCoefficient = 3; // higher numbers = more drag. Slows down faster after a drag-to-spin. % of speed to lose.
$.fn.animator = function() {
var that = this;
that.container = $(this).find('.frame-container');
that.frames = that.container.children();
that.totalFrames = that.frames.length - 1;
@lunr
lunr / rarsync.sh
Created July 19, 2012 18:50
Remote Asset Rsync Script to easily rsync assets from one server to another
#!/bin/bash
# name: rarsync - Remote Asset Rsync
# author: jamesp@teamddm.com
# date: 2012-01-23
# version 0.9.2
DEST_PATH=$2
DEST_REMOTE=0
SOURCE_PATH=$1
@lunr
lunr / smon.sh
Created August 23, 2011 15:14
Bash script to monitor a set of servers
#!/bin/bash
# This script will loop through a set of servers and print their load average,
# memory usage statistics and cpu statistics
# If a servers load average is in a warning or critical level, the text color
# of the host and the load average change to yellow (warning) or red (critical)
# The primary SSH Command has a timeout feature in it. If your server is under
# load and cannot respond fast enough, the script will alert on connection timeout.
# If you are running this script on a Mac, it will notify you by running `say`
# and bringing the terminal windows to the front
@lunr
lunr / php-json-echo-client.php
Created June 24, 2011 17:22
Python: Multi-threaded JSON Echo Server
<?php
/**
*
* PHP JSON Echo Server client
*
*/
// python server socket
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_connect($socket, 'localhost', 5555);
@lunr
lunr / jq-animation-dragdealer.js
Created May 12, 2011 18:20
Dragdealer 3D Animation Render
$(document).ready(function() {
$.fn.animator = function() {
var that = this;
var tabID = '#' + $(this).attr('id');
var frameCount = $(this).find('.frame-container').children('.frame').length;
var steps = Math.floor(frameCount + 1);
var slider = $(this).find('.dragdealer').attr('id');
var middle = Math.ceil(steps / 2.001);
@lunr
lunr / jquery-place-holder-support.js
Created March 10, 2011 20:56
jquery-place-holder-support.js
// Extend jQuery.support to test for placeholder support
$.support.placeholder = false;
test = document.createElement('input');
if('placeholder' in test) $.support.placeholder = true;
// If the placeholder attribute is not supported
// ref: http://www.cssnewbie.com/cross-browser-support-for-html5-placeholder-text-in-forms/
if(!$.support.placeholder) {
// save the active element for future reference
var active = document.activeElement;
@lunr
lunr / push-multipart.php
Created March 7, 2011 17:48
A snippet to demonstrate how to push a file upload form submission across a curl session
<?php
$data = array(
'title' => 'My Form',
'action' => 'new',
'file' => '@/path/to/file.pdf',
);
$ch = curl_init();
@lunr
lunr / popup-carousel.js
Created December 16, 2010 16:01
A simple javascript codeset for a pop-up carousel