Skip to content

Instantly share code, notes, and snippets.

@lotsofcode
lotsofcode / gist:9489410
Created March 11, 2014 16:30
angular promises resolve/reject
var $injector = angular.injector(['ng']);
var $q = $injector.get('$q');
function promise(msg) {
var defer = new $q.defer();
defer.promise.then(function() {
console.log(msg + "I promised!");
}).then(function() {
console.log(msg + "I would do this too")
}).then(function() {

Table with two columns

table.container>tr>td>table.row>tr>td.wrapper>table.six.columns>tr>td.text-pad^^^td.wrapper.last>table.six.columns>tr>td.text-pad

#!/bin/bash
rm -fr *.ova
# extract the sfx files into the respsective zip files
for SFX in *.sfx
do
echo "Extracting SFX: $SFX";
./$SFX

Google Drive File Picker Example

This is an example of how to use the Google Drive file picker and Google Drive API to retrieve files from Google Drive using pure JavaScript. At the time of writing (14th July 2013), Google have good examples for using these two APIs separately, but no documentation on using them together.

Note that this is just sample code, designed to be concise to demonstrate the API. In a production environment, you should include more error handling.

See a demo at http://stuff.dan.cx/js/filepicker/google/

require 'sinatra'
require 'premailer'
require 'json'
configure :production do
set :port, 80
end
get '/premailer' do
<<-eos
/*global angular: true, google: true, _ : true */
'use strict';
angular.module('geocoder', ['ngStorage']).factory('Geocoder', function ($localStorage, $q, $timeout) {
var locations = $localStorage.locations ? JSON.parse($localStorage.locations) : {};
var queue = [];
// Amount of time (in milliseconds) to pause between each trip to the
(function () {
var scriptName = "embed.js"; //name of this script, used to get reference to own tag
var jQuery; //noconflict reference to jquery
var jqueryPath = "http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js";
var jqueryVersion = "1.8.3";
var scriptTag; //reference to the html script tag
/******** Get reference to self (scriptTag) *********/
var allScripts = document.getElementsByTagName('script');
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<h1>Angular CORS configuration</h1>
@lotsofcode
lotsofcode / prepend-child.js
Created July 31, 2014 14:30
JavaScript implementation of "prependChild"
Element.prototype.prependChild = function(newElement) {
return this.insertBefore(newElement, this.firstChild);
};