Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Saylor cjsaylor

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am cjsaylor on github.
  • I am cjsaylor (https://keybase.io/cjsaylor) on keybase.
  • I have a public key whose fingerprint is F626 B810 0C5D 5A96 294A E24E 9F35 46F7 FA81 2DC5

To claim this, I am signing this object:

View osx-for-hackers.sh
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
@cjsaylor
cjsaylor / pre-commit
Created Apr 11, 2014
Pre-commit hook that checks code sniffer rules on PHP files
View pre-commit
#!/bin/sh
PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"`
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`
# Determine if a file list is passed
if [ "$#" -eq 1 ]
then
oIFS=$IFS
IFS='
@cjsaylor
cjsaylor / flyer.js
Created Nov 21, 2013
Eliminate those pesky flyers
View flyer.js
// Find a flyer that's at the maximum range
var flyer = _.find(roundInfo.getMobs(), function(mob) {
return mob.type === 'flyer' && mob.position === 5;
});
if (flyer) {
commander.target(flyer.id);
commander.attackMode('ranged');
return;
}
@cjsaylor
cjsaylor / category_aggregate.js
Last active Dec 27, 2015
Category aggregate query
View category_aggregate.js
var getTopCategory = function(category, callback) {
var sorter = {};
sorter[category] = -1;
this.collection('results').aggregate([
{ $sort: sorter },
{ $project: {
_id: 0,
name: 1,
category_value: '$' + category
}},
@cjsaylor
cjsaylor / mixed_resource_testcase.php
Last active Dec 27, 2015
Utilizing Mongounit's trait to allow for mongo datasources in addition to mysql datasources.
View mixed_resource_testcase.php
<?php
use \Zumba\PHPUnit\Extensions\Mongo\TestTrait as MongoTest;
class DatabaseTestCase extends \PHPUnit_Extensions_Database_TestCase {
use MongoTest {
MongoTest::setUp as mongoSetUp;
MongoTest::tearDown as mongoTearDown;
}
@cjsaylor
cjsaylor / example.php
Last active Dec 19, 2015
Google Visualization Example and HTML output
View example.php
<?php
$data = array(
'labels' => array(
array('string' => 'Sample'),
array('number' => 'Piston 1'),
array('number' => 'Piston 2')
),
'data' => array(
array('S1', 74.01, 74.03),
@cjsaylor
cjsaylor / old.php
Created Jul 10, 2013
Google Visualization CakePHP refactor
View old.php
<?php
protected function loadDataAndLabels($data, $graph_type) {
$o = '';
foreach($data['labels'] as $label) {
foreach($label as $type => $label_name) {
$o.= "data.addColumn('$type', '$label_name');\n";
}
}
$data_count = count($data['data']);
View index.html
<script src="/user/emails" type="text/javascript"></script>
@cjsaylor
cjsaylor / 5.1.js
Created Dec 3, 2012
m101 - Mongo HW 5
View 5.1.js
db.posts.aggregate( [ { $project : { 'comments.author': 1 } }, { $unwind : "$comments" }, { $group : { _id : { comments : "$comments" }, n : { $sum : 1 } } }, { $sort: {"n": -1} } ] )
You can’t perform that action at this time.