Skip to content

Instantly share code, notes, and snippets.

Avatar

Simon Bailey newtriks

View GitHub Profile
@newtriks
newtriks / Gruntfile.js
Last active Dec 25, 2015
Gruntfile with proxy logic to connect to an API (Rails) running on a separate port over localhost.
View Gruntfile.js
// 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
View albums_2.js
'use strict';
angular.module('directiveExampleApp')
.directive('albums', function() {
return {
templateUrl: 'views/templates/albums.html',
restrict: 'E',
scope: {
title: '@title'
}
View albums_1.js
'use strict';
angular.module('directiveExampleApp')
.directive('albums', function() {
return {
templateUrl: 'views/templates/albums.html',
restrict: 'E',
scope: {}
};
});
View albums.js
'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 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 / generate_thumbnail.rb
Created Apr 3, 2013
Class to generate thumbnails for images in a dir stored in an Amazon S3 bucket.
View generate_thumbnail.rb
#!/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 Feb 8, 2013
Convert PDF to JPG removing transparency and add white background using ImageSorcery (supports multi-page PDF's)
View convert_pdf_to_jpg.rb
#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 Jan 20, 2013
Join input audio files and encode to MP4 using ffmpeg
View encodeaudio.sh
#!/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 Jan 7, 2013
Sublime-build file for running Buildr-as3
View buildr-as3.sublime-build
{
"cmd": ["/usr/local/bin/rbenv", "exec", "buildr", "compile"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.ruby"
}
@newtriks
newtriks / buildfile
Created Jan 7, 2013
An example Flex buildfile for Buildr-AS3
View buildfile
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"