Skip to content

Instantly share code, notes, and snippets.

Avatar

Simon Bailey newtriks

View GitHub Profile
@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);
@newtriks
newtriks / version.sh
Created Oct 18, 2012
Versioning a Rails app with Git and Heroku
View version.sh
#!/bin/bash
REVISION=$(heroku config:get REVISION)
echo " info: heroku REVISION: $REVISION"
function version_release
{
echo -e " info: writing: '\$tagged_release_version = \"$1\"' to version_helper.rb"
echo -e "\$tagged_release_version = \"$1\"" > config/initializers/version_helper.rb
git add config/initializers/version_helper.rb
git commit -am "Updating version_helper with latest tagged version $1"
echo " info: deployed version $REVISION is not yet tagged; tagging now as $1"
@newtriks
newtriks / app.js
Last active Sep 5, 2018
Playing with immutable state using RxJS
View app.js
import {List, Record, toJS} from 'immutable';
import Rx, {Observable, Subject} from 'rx';
const initialState = Record({count: 0, text: '', items: List(), history: List(), future: List()});
const subject = new Subject();
const source = Observable.merge(subject)
.scan((currentState, action) => action(currentState), initialState());
source.subscribe(
state => {
@newtriks
newtriks / flex.sublime-build
Created Jan 7, 2013
Sublime flex build file for mxmlc compilation
View flex.sublime-build
{
"cmd": [
"/Users/newtriks/Library/Developer/SDK/flex_sdk_4.6.0.23201B/bin/mxmlc",
"$file",
"-static-link-runtime-shared-libraries=false",
"-load-config+=${file_path}/../config.xml",
"-keep-as3-metadata+=Inject",
"-keep-as3-metadata+=PostConstruct",
"-allow-source-path-overlap=true",
"-locale=en_US",
@newtriks
newtriks / index.js
Created Dec 11, 2017 — forked from bahmutov/index.js
Kleisli composition example (JSON parsing + deep property)
View index.js
// following along https://medium.com/@luijar/kliesli-compositions-in-javascript-7e1a7218f0c4
const R = require('ramda')
const Maybe = require('ramda-fantasy').Maybe
// parse JSON string into object
// parse :: String -> Object | Null
function parse(s) {
try {
return JSON.parse(s)
} catch (e) {
View webpack.config.production.js
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const PreloadWebpackPlugin = require('preload-webpack-plugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
const StyleExtHtmlWebpackPlugin = require('style-ext-html-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const autoprefixer = require('autoprefixer');
View webpack.config.production.js
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const PreloadWebpackPlugin = require('preload-webpack-plugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
const StyleExtHtmlWebpackPlugin = require('style-ext-html-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const autoprefixer = require('autoprefixer');
@newtriks
newtriks / image_scraper.rb
Created Apr 3, 2013
Sinatra script to scrape a specific xml file for image urls and upload the linked images to an Amazon S3 bucket. Change to suit your particular XML nodes.
View image_scraper.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'haml'
require 'nokogiri'
require 'aws/s3'
set :bucket, 'bucket-name'
set :s3_key, 'xxxxxx'
set :s3_secret, 'xxxxxx'
@newtriks
newtriks / logger.js
Created Jan 19, 2017 — forked from OlavHN/logger.js
redux middleware with firebase replay / remote actions
View logger.js
import Firebase from 'firebase';
const firebaseUrl = 'https://spatially.firebaseio.com/clients';
const timeOffsetUrl = 'https://spatially.firebaseio.com/.info/serverTimeOffset';
let ref = new Firebase(firebaseUrl);
let timeRef = new Firebase(timeOffsetUrl);
let cachedUid;
export default ({dispatch, getState}) => next => action => {
// The first action rehydrates, so now we've probably got the uid now