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
'use strict';
angular.module('directiveExampleApp')
.directive('albums', function() {
return {
templateUrl: 'views/templates/albums.html',
restrict: 'E',
scope: {
title: '@title'
}
'use strict';
angular.module('directiveExampleApp')
.directive('albums', function() {
return {
templateUrl: 'views/templates/albums.html',
restrict: 'E',
scope: {}
};
});
'use strict';
describe('Directive: albums', function() {
beforeEach(module('directiveExampleApp'));
var element, scope;
beforeEach(module('views/templates/albums.html'));
beforeEach(inject(function($rootScope, $compile) {
@newtriks
newtriks / image_scraper.rb
Created April 3, 2013 16:25
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.
#!/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 / generate_thumbnail.rb
Created April 3, 2013 15:53
Class to generate thumbnails for images in a dir stored in an Amazon S3 bucket.
#!/usr/bin/env ruby
###################################################
#
# Class to generate thumbnails for images in a dir
# stored in an Amazon S3 bucket.
#
# simon@newtriks.com - 10/2012
#
###################################################
@newtriks
newtriks / convert_pdf_to_jpg.rb
Created February 8, 2013 12:34
Convert PDF to JPG removing transparency and add white background using ImageSorcery (supports multi-page PDF's)
#https://github.com/EricR/image_sorcery
require 'image_sorcery'
image = ImageSorcery.new("example.pdf")
image.manipulate!(format: "jpg", :resize => '400x300', :quality => 100, :density => 150, :background => 'white', :alpha => 'Remove')
@newtriks
newtriks / encodeaudio.sh
Created January 20, 2013 12:33
Join input audio files and encode to MP4 using ffmpeg
#!/bin/bash
# the version of the script
VERSION=1.0
echo "------------------------------------------"
echo "Audio Specific Concat Script v$VERSION - A script to concatenate multiple audio files and encode to MP4."
echo "Based on FFmpeg - www.ffmpeg.org and http://goo.gl/eDFeM"
echo "------------------------------------------"
@newtriks
newtriks / buildr-as3.sublime-build
Created January 7, 2013 21:37
Sublime-build file for running Buildr-as3
{
"cmd": ["/usr/local/bin/rbenv", "exec", "buildr", "compile"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.ruby"
}
@newtriks
newtriks / buildfile
Created January 7, 2013 21:25
An example Flex buildfile for Buildr-AS3
require "fileutils"
require "buildr/as3" # needs - gem install buildr-as3 -v "0.2.30.pre"
# Version number for this release will become dynamic
VERSION_NUMBER = "0.0.1"
# Group identifier for your projects
GROUP = "com.newtriks"
COPYRIGHT = "newtriks.com"