Skip to content

Instantly share code, notes, and snippets.

View shama's full-sized avatar
✍️
writing a status message

Kyle Robinson Young shama

✍️
writing a status message
View GitHub Profile
@shama
shama / Gruntfile.js
Created February 24, 2014 19:12
Simple gruntfile that compiles with compass
module.exports = function(grunt) {
grunt.initConfig({
compass: {
dist: {
options: {
sassDir: 'sass',
cssDir: 'css',
environment: 'production',
},
},
@shama
shama / favorite_module_pattern.js
Last active August 29, 2015 13:57
My favorite node.js module pattern
function Animal(name) {
if (!(this instanceof Animal)) return new Animal(name);
this.name = name || 'unknown';
}
module.exports = Animal;
Animal.prototype.feed = function(food) {
food = food || 'food';
return 'Fed ' + this.name + ' some ' + food;
};

Method for triggering an action on any controller from a component, such as with nested Ember components.

WARNING: You really shouldn't do this as it couples your component to your app, which kind of defeats the purpose of the component, right?

GlobalAction = Ember.Mixin.create
  triggerGlobalAction: (action, controller="application", args...) ->
    @triggerAction
      action: action
 target: @container.lookup('controller:' + controller)
@shama
shama / async-vs-sync.js
Created April 25, 2014 16:20
Comparing async vs sync functions in node.js
function sync(callback) {
callback()
}
function async(callback) {
process.nextTick(function() {
callback()
})
}

Keybase proof

I hereby claim:

  • I am shama on github.
  • I am shama (https://keybase.io/shama) on keybase.
  • I have a public key whose fingerprint is F6D7 6C36 9C6E AB90 7590 17EB 2F62 CF16 5E42 E438

To claim this, I am signing this object:

@shama
shama / downup.js
Created April 27, 2015 00:37
Data down, actions up idea module
var h = require('virtual-dom/h')
var xtend = require('xtend/mutable')
var merge = require('xtend')
function DownUp(data) {
if (!(this instanceof DownUp)) return new DownUp(data)
var self = this
this.set({
tagName: 'div',
childViews: [],
@shama
shama / cakeftp_mocks.php
Created October 26, 2011 21:02
Mocking up CakeFTP
/**
* testConnect
*/
public function testConnect() {
// FTP FAILED CONNECT
$this->FtpSource = $this->getMock('FtpSource', array('_ftp'), array($this->defaultConfig));
$callback = create_function('$method,$params', <<<END
if (\$method == "ftp_connect") {
return false;
@shama
shama / keyzoom.js
Created February 2, 2012 00:01
jmpress.js zoom in and out with + or -
/**
* Viewport Key Zoom In & Out
* Press + and - to zoom the viewport in and out.
*/
(function() {
'use strict';
$.jmpress("defaults").viewPort.keyZoomAmount = 100;
$.extend(true, $.jmpress('defaults').keyboard.keys, {
187: 'zoomin' // plus
,189: 'zoomout' // minus
@shama
shama / FixAssertShell.php
Created March 23, 2012 06:39
Correct parameter order of assertions
<?php
App::uses('Folder', 'Utility');
App::uses('File', 'Utility');
/**
* Fix Assert Shell
* Will correct the parameter ordering of assertEquals()
* Not perfect but gets most and only causes a few errors :)
*
* @author Kyle Robinson Young <kyle at dontkry.com>
@shama
shama / questionable-game.md
Created March 27, 2012 04:17
The Questionable Game

The Questionable Game

A game to play when answering questions in a support channel of an open source project to get people to read the docs.

How To Play

  • The player asks a question.
  • If the answer can be found in the docs/wiki, the player gets 1 point.
  • If the answer can be found in the readme, the player gets 1.5 points.
  • If the answer can be found with a google search, the player gets 0.5 points.