Skip to content

Instantly share code, notes, and snippets.

View newtriks's full-sized avatar

Simon Bailey newtriks

View GitHub Profile
@newtriks
newtriks / Gruntfile.js
Last active December 25, 2015 16:59
Gruntfile with proxy logic to connect to an API (Rails) running on a separate port over localhost.
// Generated on 2013-10-11 using generator-angular 0.4.0
'use strict';
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({ port: LIVERELOAD_PORT });
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
// # Globbing
package net.fkasoft.wowzamod;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@newtriks
newtriks / file.js
Created February 6, 2014 18:35
NodeJS module to download multiple files from Amazon S3
#!/usr/bin/env node
var Q = require('q'),
FS = require('fs'),
PB = require('progress'),
AWS = require('aws-sdk'),
conf = new require('../config')();
AWS.config.update(conf.aws_credentials);
@newtriks
newtriks / crop.js
Created February 7, 2014 14:33 — forked from arian/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 February 10, 2014 15:58
Example HTTP POST with JSON body data using Q based on reported issue https://github.com/kriskowal/q-io/issues/8#issuecomment-34633958
var body = JSON.stringify({
token: 'foo',
files: files // Array of filenames
});
var headers = {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(body, 'utf8')
};
"scripts": {
"test": "grunt travis --verbose"
}
@newtriks
newtriks / no-sudo-npm.md
Created July 3, 2014 08:05
Non-sudo npm -g installation
  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 / angular-gulp-setup.md
Last active November 7, 2015 13:29
Project setup for: angular, gulp, bower, testem and protractor
  1. Install global dependencies: npm install -g browserify gulp bower testem protractor
  2. Install local npm dependencies: npm install
  3. Install local bower dependencies: gulp bowerInstall
  4. Install Protractor specific webdrivers: webdriver-manager update
  5. Build project into dist directory: gulp build
  6. Run application on local webserver plus watch for changes: gulp watch
  7. Run unit tests: testem
  8. Run end-to-end tests: gulp protractor (gulp watch must be running in as another process i.e. in another console window).
@newtriks
newtriks / bower.js
Created July 3, 2014 11:23
Gulp task to run bower install/update and remove dependencies.
var gulp = require('gulp');
var bower = require('bower');
var del = require('del');
var _ = require('lodash');
var deleteDeps = function (deps, cb) {
var path = bower.config.cwd + "/" + bower.config.directory;
_.each(deps, function (dep) {
del(path + "/" + dep, function (e) {});
});
@newtriks
newtriks / app.js
Created July 8, 2014 11:02
Example using provider and ng-mixin
angular.module('app', []).config(require('./common/exceptions’));