Skip to content

Instantly share code, notes, and snippets.

Avatar

Simon Bailey newtriks

View GitHub Profile
View gist:eae45ff9d9aeb9788bb0
-*.min.js,-*.min.map,-app/_bower_components/*,-node_modules/*,-.tmp/*,-.jekyll/*,-.sass-cache/*,-dist/*,-public/*,-tmp/*,-vendor/bundle/*
@newtriks
newtriks / app.js
Created Jul 8, 2014
Example using provider and ng-mixin
View app.js
angular.module('app', []).config(require('./common/exceptions’));
@newtriks
newtriks / bower.js
Created Jul 3, 2014
Gulp task to run bower install/update and remove dependencies.
View bower.js
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 / angular-gulp-setup.md
Last active Nov 7, 2015
Project setup for: angular, gulp, bower, testem and protractor
View angular-gulp-setup.md
  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 / 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)
View package.json
"scripts": {
"test": "grunt travis --verbose"
}
@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 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 / file.js
Created Feb 6, 2014
NodeJS module to download multiple files from Amazon S3
View file.js
#!/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);
View WowzaMod.java
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;