Skip to content

Instantly share code, notes, and snippets.

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/

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

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

@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() {
@lotsofcode
lotsofcode / epsilon-greedy-method.php
Last active December 19, 2019 06:28
epsilon-greedy-method.php
<?php
/*
@ref http://stevehanov.ca/blog/index.php?id=132
def choose():
if math.random() < 0.1:
# exploration!
# choose a random lever 10% of the time.
else:
# exploitation!
# for each lever,

The idea is to have nginx installed and node installed. I will extend this gist to include how to install those as well, but at the moment, the following assumes you have nginx 0.7.62 and node 0.2.3 installed on a Linux distro (I used Ubuntu).

In a nutshell,

  1. nginx is used to serve static files (css, js, images, etc.)
  2. node serves all the "dynamic" stuff.

So for example, www.foo.com request comes and your css, js, and images get served thru nginx while everything else (the request for say index.html or "/") gets served through node.

  1. nginx listens on port 80.
@lotsofcode
lotsofcode / gist:5626525
Created May 22, 2013 10:05
javascript duplicate function
Array.prototype.duplicate = function() {
return this.concat(this);
}
var duped = [1,2,3,4,5].duplicate()
console.log(duped)

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

function yeoapp() {
local dirname="$1"
if [ "$dirname" = "" ]; then
echo "usage: yeoman $dirname";
return 1;
fi
if [ -d "$dirname" ]; then
echo "'$dirname' exists, please choose another";
@lotsofcode
lotsofcode / gist:5157069
Created March 13, 2013 22:37
write already install bower components to component.json file
for component in $(ls components --color=never); do bower install $component --save; done;