Skip to content

Instantly share code, notes, and snippets.

<!doctype html>
<!--[if (IE 9) & (!IEMobile)]> <html class="no-js ie-9" lang="en-au"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en-au"> <!--<![endif]-->
<head>
<script>
(function() {
var html = document.getElementsByTagName('html')[0]
html.className = html.className.replace( /(?:^|\s)no-js(?!\S)/g , 'js' );
})()
</script>
@dansimco
dansimco / directive-as-a-service.js
Created February 3, 2014 08:22
Angular Directive as a Service
angular.module('MyComponent', [])
.service('MyComponent', function($log, $rootScope, $compile) {
return function(params) {
var scope;
// Pass params through to a new'd up scope.
// I'm just shoving them all in there as a property
// but you could be more discreet.
scope = $rootScope.$new();
scope.params = params;
var directive = $compile('<my-component>')(scope);
@dansimco
dansimco / Gruntfile.js
Last active August 29, 2015 13:55
Modularized Gruntfile
module.exports = function(grunt) {
//Load private config if available
try {
app_config = grunt.file.readJSON('config.json');
} catch (err) {
console.log(
"\n\nNo config file found. Some tasks may require config strings such as AWS keys or DB strings" +
"Please create one based on config.sample.json\n\n"
);
@dansimco
dansimco / uploadPhotoToFacebook.js
Created January 2, 2013 04:27
Posts a photo to a users profile, creating a gallery where needed.
/*global FB, alert, console */
//Usage
// uploadPhotoToFacebook({
// caption: 'A Picture',
// url: 'http://lorempixel.com/400/300/',
// album: 'JS API',
// album_description: "An album of pictures",
// onSuccess: function(){
@dansimco
dansimco / gist:3106555
Created July 13, 2012 18:38
InstantFileUploader
/*global Element, IFrame, document, Button */
var InstantFileUploader;
InstantFileUploader = function (input, params) {
"use strict";
var self = this;
self.frameId = String.uniqueID();
self.loading = false;
self.onComplete = params.onComplete || function () {};
@dansimco
dansimco / gist:3067704
Created July 7, 2012 19:08
touchUpInside
isTouchInside = function(e){
var event = e.originalEvent;
touch_inside = false;
if (! event.touches[0] ) return touch_inside;
touchX = event.touches[0].pageX;
touchY = event.touches[0].pageY;
if(
touchX > element_coords.left &&
touchX < element_coords.right &&
touchY > element_coords.top &&
@dansimco
dansimco / app.rb
Created May 29, 2012 15:09
Concise Sinatra Amazon S3 Upload Example
require "rubygems"
require 'sinatra'
require "aws/s3"
get '/' do
return %Q{
<form action="upload" method="post" accept-charset="utf-8" enctype="multipart/form-data">
<div>
<input type="file" name="file" value="" id="file">
</div>
@dansimco
dansimco / SEHGymRules.md
Created May 15, 2012 21:05
Draft for SEH Gym rules poster

##NSE Gym

##PICK UP AFTER YOURSELF

  • Return weight plates, bars and dumbbells to their designated places when not in use.
  • Throw your paper towels and rubbish in the trash.
  • DO NOT leave dumbbells on the floor or weight plates on the bar.
  • If you move equipment, put it back where it belongs (Otherwise the porters are unable to clean the gym effectively).

##NOISE


#HBG

Financially distressed businesses within Australia seeking re-engineering, re-structuring and a strategy to trade out of their existing problem. Businessess seeking support of corporate strategists to grow their business, protect their assets and investigate new areas. Businesses that have grown beyond their resources and want to bring on a specialised level of accounting and business support. High net worth individuals seeking personal advisor and gatekeeper.

##Services

  • Accountancy
@dansimco
dansimco / gist:767668
Created January 6, 2011 08:10
poopevent
btn.addEvent('touchend',function(event){
var touchX = event.event.changedTouches[0].pageX;
var touchY = event.event.changedTouches[0].pageY;
var spotCoords = btn.getCoordinates();
if(touchX>spotCoords.left && touchX<spotCoords.right && touchY>spotCoords.top && touchY<spotCoords.bottom){
alert('TouchUpInside!!!');
} else {
alert('Touch up outside');
}
});