Skip to content

Instantly share code, notes, and snippets.

@wayneashleyberry
wayneashleyberry / gist:3341219
Created August 13, 2012 14:27
Set Facebook iFrame height
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
@wayneashleyberry
wayneashleyberry / gist:3357725
Created August 15, 2012 08:50
update all projects
for dir in ~/knnktr/*;
do (cd $dir && git pull origin master);
done;
@wayneashleyberry
wayneashleyberry / gist:3634563
Created September 5, 2012 10:18
bootstrap data for require.js
<!-- require -->
<script data-main="/js/main" src="/js/vendor/require-2.0.6.js"></script>
<!-- data -->
<script>
define('data', [], function () {
return <?= json_encode($bootstrap); ?>;
});
</script>
@wayneashleyberry
wayneashleyberry / t.js
Created September 28, 2012 12:46
simple templating
/**
* simple mustache-like templater
* http://mir.aculo.us/2011/03/09/little-helpers-a-tweet-sized-javascript-templating-engine/
* -----------------------------------------------------------------------------------------
* t('Hello, {{planet}}!', array('planet' => 'World');
* returns 'Hello, World!';
*/
function t(s,d){
for(var p in d)
s=s.replace(new RegExp('{{'+p+'}}','g'), d[p]);
@wayneashleyberry
wayneashleyberry / gist:3821399
Created October 2, 2012 17:26
javascript endsWith function
String.prototype.endsWith = function (str) {
if (this.substr(-str.length) === str) {
return true;
}
return false;
};
@wayneashleyberry
wayneashleyberry / gist:3893207
Created October 15, 2012 15:49
fuzzy string matching in javascript
var people = ['Daniel', 'Dustin', 'David', 'Damarcus', 'Russ'];
function matchPeople(input) {
var regex = new RegExp('[' + input.split('').join(']+.*[') + ']+', 'ig');
return people.filter(function(person) {
if (person.match(regex)) return person;
});
}
console.log(matchPeople('dvd')); // returns ['David']
@wayneashleyberry
wayneashleyberry / color.php
Created October 17, 2012 14:06
php color manipulation
<?php
function hex2rgb( $col ) {
if ( $col[0] == '#' ) {
$col = substr( $col, 1 );
}
if (strlen( $col ) == 6) {
list( $r, $g, $b ) = array( $col[0] . $col[1], $col[2] . $col[3], $col[4] . $col[5] );
} elseif (strlen( $col ) == 3) {
list( $r, $g, $b ) = array( $col[0] . $col[0], $col[1] . $col[1], $col[2] . $col[2] );
@wayneashleyberry
wayneashleyberry / eloquent.php
Created November 1, 2012 10:47
key-value storage for eloquent models
<?php
namespace App;
// add key-value storage to models
class Eloquent extends \Eloquent {
protected $metaClass = 'ObjectMeta';
@wayneashleyberry
wayneashleyberry / sms.php
Created November 12, 2012 10:54
send sms via bulk sms api
<?php
function sendsms($number, $message)
{
$username = 'username';
$password = 'password';
//set POST variables
$url = 'http://bulksms.2way.co.za/eapi/submission/send_sms/2/2.0';
@wayneashleyberry
wayneashleyberry / config.error.php
Created November 12, 2012 21:10
testing laravel errors
<?php
return array(
'ignore' => array(),
'detail' => true,
'log' => true,
'logger' => function($exception)
{
die($exception);
}