Skip to content

Instantly share code, notes, and snippets.

<?php
usort($unsortedObjectArray, function( $a, $b ) {
if ($a->weight == $b->weight) {
return 0;
}
return ($a->weight < $b->weight) ? -1 : 1;
});
#!/usr/bin/env python
#
# Converts any integer into a base [BASE] number. I have chosen 62
# as it is meant to represent the integers using all the alphanumeric
# characters, [no special characters] = {0..9}, {A..Z}, {a..z}
#
# I plan on using this to shorten the representation of possibly long ids,
# a la url shortenters
#
@zircote
zircote / ga-analytics.js
Created March 26, 2013 19:47
Get the clientId for the universal analytics
tracker = ga.getByName('tracker')
tracker.get('clientId')
@zircote
zircote / cake-example.php
Created March 22, 2013 20:14
I am not familiar with cake; however based on the example I was given this should produce the desired result.
<?php
use Swagger\Annotations as SWG;
App::uses('AppController', 'Controller');
/**
* Users Controller
* @SWG\Resource(
* apiVersion="0.2",
* swaggerVersion="1.1",
* basePath="http://api.myhost.local/api",
* resourcePath="/users"
mysql -u username dbname -e 'describe db_table'|awk '{print " protected $"$1";"};'
@zircote
zircote / r53-dyn-dns.sh
Created January 21, 2013 12:07
Automated DNS updates using Route53
#!/bin/sh
ZONE="my-tld.com"
RESOURCE="some-host"
INTERFACE="eth0"
ADDR=$(ifconfig $INTERFACE | grep "inet addr" | awk -F: '{print $2}' | awk '{print$1}')
cli53 rrcreate $ZONE $RESOURCE A $ADDR -x 3600 -r
<?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>Disabled</key>
<false/>
<key>KeepAlive</key>
<false/>
<key>Label</key>
<string>com.zircote.headlessvm</string>
@zircote
zircote / composer.sh
Created December 13, 2012 16:54
Got tired of finding I was not running latest composer version.
#!/bin/bash
COMPOSER=$(type -p "composer.phar")
if [ -x "${COMPOSER}" ]; then
${COMPOSER} self-update > /dev/null
else
$(type -p "php") -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
fi
${COMPOSER} $@
@zircote
zircote / cluster-members.txt
Created November 19, 2012 06:32
Pear install
[ zircote ~/Workspace/Jazsl ] zf cluster-status jazsl-server zcsm
Cluster Members:
┌──────────┬───────────────┬───────────────┬────────────────────────────────────────────────────────────┐
│Server ID │Status │Instance-Name │URI │
├──────────┼───────────────┼───────────────┼────────────────────────────────────────────────────────────┤
│25 │OK │i-07982fff │ec2-00-00-00-01.compute-1.amazonaws.com │
├──────────┼───────────────┼───────────────┼────────────────────────────────────────────────────────────┤
│28 │OK │i-25765fff │ec2-00-00-00-00.compute-1.amazonaws.com │
├──────────┼───────────────┼───────────────┼────────────────────────────────────────────────────────────┤
│31 │OK │i-2e988fff │ec2-00-00-00-00.us-west-1.compute.amazonaws.com │
@zircote
zircote / ec2_name.sh
Created November 16, 2012 18:26
Route53 Hostname Injection
#!/bin/bash
#
# @c Robert Allen zircote@gmail.com
#
# /usr/bin/ec2_name
if [ -f /etc/profile.d/aws-apitools-common.sh ]; then
. /etc/profile.d/aws-apitools-common.sh
export PATH=/opt/aws/bin:$PATH
fi