Skip to content

Instantly share code, notes, and snippets.

View freshtonic's full-sized avatar
🎯

James Sadler freshtonic

🎯
  • Sydney, Australia
View GitHub Profile
@freshtonic
freshtonic / gist:5034047
Last active December 14, 2015 05:18
How to boot an Angular.js app asynchronously (e.g. when using webshims).
$.webshims.setOptions 'basePath', "/js-webshim/minified/shims/"
# $.webshims.setOptions 'basePath', "/js-webshim/dev/shims/"
# ES5 provides Array and String methods (and other misc) that are missing in
# older browsers.
$.webshims.polyfill 'es5'
# Boot Angular.js manually. We can't do it with ng-app anymore because we need
# the polyfills to be loaded before Angular, but the polyfills load asynchronously.
$ ->
[color]
branch = auto
diff = auto
status = true
ui = true
@freshtonic
freshtonic / gist:4173737
Created November 30, 2012 04:12
This looks like it will do the job
require File.dirname(__FILE__) + '/config/boot'
require './blaze_control_panel'
application = Rack::Builder do
use Rack::SslEnforcer if ENV['RACK_ENV'] == 'production'
use Rack::CommonLogger, File.new('log/access.log', 'a+')
use GoogleOpenIdAuth
run Rack::Cascade.new [::API::V1::Blaze, BlazeControlPanel]
~ ⮁ pinion ⮁ oimtool ⮀ master + ⮀ $ ⮀oim ec2 add bcp
path.existsSync is now called `fs.existsSync`.
Identity added: /Users/jamessadler/.ssh/oim-cp.pem (/Users/jamessadler/.ssh/oim-cp.pem)
knife ec2 server create --ssh-user=ubuntu --image=ami-a29943cb --flavor=m1.small --groups=bcp --run-list=role[base],role[bcp] --region=us-east-1 --availability-zone=us-east-1a --ssh-key=oim-cp --tags=Name=bcp-us --node-name=bcp-us
Instance ID: i-af361cd0
Flavor: m1.small
Image: ami-a29943cb
Region: us-east-1
Availability Zone: us-east-1a
Security Groups: bcp
forEach(actions, function(action, name) {
var hasBody = action.method == 'POST' || action.method == 'PUT' || action.method == 'PATCH';
FancyResource[name] = function(a1, a2, a3, a4) {
var params = {};
var data;
var success = noop;
var error = null;
switch(arguments.length) {
case 4:
@freshtonic
freshtonic / gist:4015496
Created November 5, 2012 05:24
Angular JS injection
CreativesController = ($scope, Creative, flash) ->
Creative.query (creatives) ->
$scope.creatives = creatives
# Delete an Creative
$scope.remove = (creative) ->
success = ->
$scope.creatives = _.reject $scope.creatives, (s) -> s is creative
flash.success 'successfully deleted creative'
error = ->
filename = "some file name.with dots.html.markdown"
parts = f.split(".")
last_index_of_spc = parts.index(parts.select{|s| s =~ / /}.last)
suffix = parts[last_index_of_spc + 1..-1]
prefix = parts[0..last_index_of_spc].join(".")
p [prefix, suffix]
@freshtonic
freshtonic / gist:3607468
Created September 3, 2012 07:01
effingPuts
global.effingPuts = ( ->
fs = require 'fs'
sys = require 'sys'
(msg) ->
if typeof msg is 'String'
fs.writeSync 1, msg
else
fs.writeSync 1, sys.inspect(msg)
fs.fsyncSync 1
)()
@freshtonic
freshtonic / gist:3494515
Created August 28, 2012 02:53
AngularJS stuff I'm just not getting my head around
doctype 5
html(lang="en", ng-app="blaze-control-panel")
head
title 'Blaze Control Panel'
meta(name="viewport", content="width=device-width, initial-scale=1.0")
link(href="css/bootstrap.css", rel="stylesheet", type="text/css")
link(href="css/bootstrap-responsive.css", rel="stylesheet", type="text/css")
link(href="css/app.css", rel="stylesheet", type="text/css")
script(src='js/lib/jquery-1.8.0.min.js')
script(src='js/lib/underscore-1.3.3.min.js')
@freshtonic
freshtonic / gist:2843057
Created May 31, 2012 12:26
no one was ready for it yet
For example, I was co-founder of a startup called Neowurks (yeah shit name)
about 10 years ago.
It was an app for the telco industry, in the area of rates exchange and route
provisioning.
At least once per week, all the telcos would exchange their rates for
terminating calls at major cities around the world. Pricing was per million
minutes, at 4 or 5 levels of quality of service and for mobile versus landline.