Skip to content

Instantly share code, notes, and snippets.

Avatar

Simon Bailey newtriks

View GitHub Profile
View crop.js
var spawn = require('child_process').spawn;
var Stream = require('stream');
/**
* crops and resizes images to our desired size
* @param {Stream} streamIn in stream containing the raw image
* @return {Stream}
*/
exports.cropImage = function(streamIn){
@newtriks
newtriks / Q_post_example.js
Created Feb 10, 2014
Example HTTP POST with JSON body data using Q based on reported issue https://github.com/kriskowal/q-io/issues/8#issuecomment-34633958
View Q_post_example.js
var body = JSON.stringify({
token: 'foo',
files: files // Array of filenames
});
var headers = {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(body, 'utf8')
};
View package.json
"scripts": {
"test": "grunt travis --verbose"
}
@newtriks
newtriks / no-sudo-npm.md
Created Jul 3, 2014
Non-sudo npm -g installation
View no-sudo-npm.md
  1. npm set prefix ~/.node
  2. export PATH=$HOME/.node/bin:$PATH >> ~/.profile
  3. wget http://npmjs.org/install.sh or simply download via your browser. This is a shell script from npmjs.org and I found to be safe to run, please ensure you're happy before executing the script.
  4. sh install.sh (note: not sudo)
@newtriks
newtriks / app.js
Created Jul 8, 2014
Example using provider and ng-mixin
View app.js
angular.module('app', []).config(require('./common/exceptions’));
View gist:eae45ff9d9aeb9788bb0
-*.min.js,-*.min.map,-app/_bower_components/*,-node_modules/*,-.tmp/*,-.jekyll/*,-.sass-cache/*,-dist/*,-public/*,-tmp/*,-vendor/bundle/*
@newtriks
newtriks / gist:4f1fcef9da7dde4c91bf
Last active Aug 29, 2015
If using #OSX LiveReload app add to ‘Run a custom command’ which’ll display a notification #Mavericks
View gist:4f1fcef9da7dde4c91bf
osascript -e 'display notification "Reloaded browser..." with title "LiveReload"'
View PopUpCombo.as
package
{
import flash.display.DisplayObject;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.ui.Keyboard;
import mx.controls.PopUpButton;
@newtriks
newtriks / gist:1016612
Created Jun 9, 2011
Run command with rake test
View gist:1016612
task :default => :list do
%x{touch readme.txt}
end
task :list do
@dump=%x{ls}
puts "Directory contents: #{@dump}"
end
@newtriks
newtriks / FlexTestRunner.mxml
Created Jun 10, 2011
Flex ASUnit4 TestRunner
View FlexTestRunner.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
minWidth="800"
minHeight="600"
creationComplete="creationCompleteHandler(event)">
<fx:Script>
<![CDATA[
import asunit.core.TextCore;