Skip to content

Instantly share code, notes, and snippets.

View CurtisHumphrey's full-sized avatar

Curtis M. Humphrey, Ph.D. CurtisHumphrey

View GitHub Profile
@CurtisHumphrey
CurtisHumphrey / packages.md
Last active October 15, 2018 15:39
Sublime Text 3
  • Babel
  • Case Conversion
  • CSS Extended Completions
  • DocBlockr
  • EditorConfig
  • ESLint-Formatter
  • GitGutter
  • Hex to HSL Color Converter
  • HTML-CSS-JS Prettify
  • JsFormat
@CurtisHumphrey
CurtisHumphrey / CoffeeComplete Plus Custom Types.sublime-settings
Last active December 19, 2015 12:09
Adds Knockout.js support for CoffeeComplete Plus
{
"coffee_autocomplete_plus_custom_types": [
{
"name": "ko",
"enabled": true,
"constructors": [
{
"args": []
}
],
@CurtisHumphrey
CurtisHumphrey / empty_all()
Created July 14, 2013 00:48
codeigniter php code for truncating all tables and reset auto_increments
function empty_all()
{
$query = $this->db->query("SHOW TABLES");
$name = $this->db->database;
foreach ($query->result_array() as $row)
{
$table = $row['Tables_in_' . $name];
$this->db->query("TRUNCATE " . $table);
$this->db->query("ALTER TABLE ".$table." AUTO_INCREMENT = 1");
}
@CurtisHumphrey
CurtisHumphrey / check_existance
Created July 14, 2013 00:51
PHP php-activerecord code for checking existence and reusing before creating
//validations
static $validates_presence_of = array( //TODO
//alterations
static $before_create = array('check_existence');
function check_existence()
{
$find_by = array();
foreach(self::$validates_presence_of as $key)
@CurtisHumphrey
CurtisHumphrey / post-receive
Last active December 23, 2015 03:29
git hooks
#!/usr/bin/env ruby
# Aside from removing Ruby on Rails specific code this is taken verbatim from
# mislav's git-deploy (http://github.com/mislav/git-deploy) and it's awesome
# - Ryan Florence (http://ryanflorence.com)
#
# Install this hook to a remote repository with a working tree, when you push
# to it, this hook will reset the head so the files are updated
if ENV['GIT_DIR'] == '.'
@CurtisHumphrey
CurtisHumphrey / fisher_yates_shuffle.coffee
Created December 30, 2013 22:24
Fisher-Yates shuffle (in-place) in coffeescript
###
Randomize array element order in-place.
Using Fisher-Yates shuffle algorithm.
###
shuffleArray = (array) ->
i = array.length - 1
while i > 0
j = Math.floor(Math.random() * (i + 1))
temp = array[i]
@CurtisHumphrey
CurtisHumphrey / Gruntfile.coffee
Last active August 29, 2015 13:56
Gruntfile for knockout, coffeescript, jasmine
module.exports = (grunt) ->
# Livereload and connect variables
LIVERELOAD_PORT = 35729
lrSnippet = require("connect-livereload")(port: LIVERELOAD_PORT)
mountFolder = (connect, dir) ->
connect.static require("path").resolve(dir)
grunt.initConfig
connect:
dev:
@CurtisHumphrey
CurtisHumphrey / zIndex.js
Last active August 29, 2015 14:01
z-index finder
var elem = this.$element.parent(), position, value;
while ( elem.length && elem[ 0 ] !== document )
{
// Ignore z-index if position is set to a value where z-index is ignored by the browser
// This makes behavior of this function consistent across browsers
// WebKit always returns auto if the element is positioned
position = elem.css( "position" );
if ( position === "absolute" || position === "relative" || position === "fixed" ) {
// IE returns 0 when zIndex is not specified
// other browsers return a string
@CurtisHumphrey
CurtisHumphrey / private_items.json
Last active October 1, 2018 20:44
Firebase Rules Examples
// Supports pushing new items
"private": {
".read": false,
".write": false,
"$item": {
".read": "auth != null && auth.uid == data.child('uid').val()",
".write": "auth != null &&
/*update*/ ((data.exists() && auth.uid == data.child('uid').val())
/*new*/ || (!data.exists() && auth.uid == newData.child('uid').val()))"
}
@CurtisHumphrey
CurtisHumphrey / exists.coffee
Created July 19, 2014 15:54
Firebase check for existance
Check_Event: (ref, child, callback) ->
ref
.child child
.once 'value', (snapshot) ->
exists = snapshot.val() isnt null
callback exists
return