Skip to content

Instantly share code, notes, and snippets.

@ryanneufeld
ryanneufeld / mlqueue
Created October 11, 2012 21:36
Array prototype example
/**
* This script will process a queue of events. The event queue can be built up before
*
* http://cl.ly/image/1b001E3b1c0A
*
*/
var _mlq = _mlq || [];
function mlQueue(_q, name) {
function _Q() {}
@ryanneufeld
ryanneufeld / gist:3901357
Created October 16, 2012 19:17
mkdir -p examples.
/tmp# mkdir -p one/{two,three/five}/{four,six/{seven,eight}}
/tmp# tree one/
one/
├── three
│   └── five
│   ├── four
│   └── six
│   ├── eight
│   └── seven
└── two
// get the list of laptops
$laptops = $this->laptop_model->get_laptops();
// get laptop details
$laptopDetails = array();
foreach($laptops as $laptop) {
$laptopDetails[$laptop->id] = $this->laptop_model->get_laptop_details($laptop->id);
}
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| Enable memcache
|--------------------------------------------------------------------------
|
| $config['memcache'] = true|false;
|
*/
$config['memcache'] = false;
$(document).ready(function() {
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
/*Here 200 is your divs (check) hight replace it with your required hight alos make required changes at style.*/
$("#body").css('margin-top', winH/2 - 469/2);
/*Here 300 is your divs (check) width replace it with your required width alos make required changes at style.*/
$("#body").css('margin-left', winW/2 - 990/2);
@ryanneufeld
ryanneufeld / gist:4448251
Last active December 10, 2015 14:29
Colorize CodeIgniter logs. ``` $ ci_color_log_tail /path/to/application/logs/log-2013-01-03.php $ ci_color_log_tail /path/to/application/logs/log-2013-01-03.php 300 #start with 300 lines of log. ```
# This version colors only the keyword at the beginning of the line
ci_color_log_tail() {
tail -f -n ${2:-100} $1 | awk '{if ($1 == "DEBUG") { c=34 } else if ($1 == "WARNING") { c=32 } else if ($1 == "ERROR") { c=31 } else { c=39 }; printf "\033[1;" c "m%s\033[0m ", $1; for (i = 2; i <= NF; i++) printf $i " "; printf "\n"}'
}
# This version colors the entire line.
ci_color_log_tail() {
tail -f -n ${2:-100} $1 | awk '{if ($1 == "DEBUG") { c=34 } else if ($1 == "WARNING") { c=32 } else if ($1 == "ERROR") { c=31 } else { c=39 }; printf "\033[1;" c "m%s\033[0m\n", $0;}'
}
<?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>name</key>
<string>Solarized (dark)</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
payload=%7B%22repository%22%3A+%7B%22website%22%3A+%22%22%2C+%22fork%22%3A+false%2C+%22name%22%3A+%22ryanneufeld.net%22%2C+%22scm%22%3A+%22git%22%2C+%22absolute_url%22%3A+%22%2Fryanneufeld%2Fryanneufeld.net%2F%22%2C+%22owner%22%3A+%22ryanneufeld%22%2C+%22slug%22%3A+%22ryanneufeld.net%22%2C+%22is_private%22%3A+true%7D%2C+%22commits%22%3A+%5B%7B%22node%22%3A+%221a1723ccf659%22%2C+%22files%22%3A+%5B%7B%22type%22%3A+%22added%22%2C+%22file%22%3A+%22wee.txt%22%7D%5D%2C+%22branch%22%3A+%22master%22%2C+%22utctimestamp%22%3A+%222013-01-22+22%3A45%3A03%2B00%3A00%22%2C+%22author%22%3A+%22ryanneufeld%22%2C+%22timestamp%22%3A+%222013-01-22+23%3A45%3A03%22%2C+%22raw_node%22%3A+%221a1723ccf6593c547a60b251830cab951fcad0da%22%2C+%22parents%22%3A+%5B%22ebe6617dbcf1%22%2C+%22d05a0e5dc507%22%5D%2C+%22raw_author%22%3A+%22Ryan+Neufeld+%3Cryan%40neufeldmail.com%3E%22%2C+%22message%22%3A+%22Merged+in+develop+%28pull+request+%232%29%5Cr%5Cn%5Cr%5Cnfa%22%2C+%22size%22%3A+-1%2C+%22revision%22%3A+null%7D%5D%2C+%22canon_url%22%3A+%22http
Including /Users/ryan/workspace/node-notifier-server/notifier.d/puppet.js
Setting up post-receive server on port 3333
spawn: puppet.sh fddd0da355e781da3857823092a6d65528ebb1d8
puppet.sh:exit:0
/Users/ryan/workspace/node-notifier-server/notifier-server.js:71
mailer( os.hostname() + ": Deployment: " + filename + " " + data.commit, ou
^
TypeError: undefined is not a function
at ChildProcess.<anonymous> (/Users/ryan/workspace/node-notifier-server/notifier-server.js:71:4)
{
"canon_url":"https://bitbucket.org",
"commits":[
{
"author":"ryanneufeld",
"branch":null,
"branches":[
],
"files":[