Skip to content

Instantly share code, notes, and snippets.

View leegee's full-sized avatar

Lee Goddard leegee

View GitHub Profile
@repeatingbeats
repeatingbeats / nodeunit_example.js
Created January 27, 2011 20:07
Example structure for nodeunit tests with nested groups and setUp/tearDown functions
/**
* Example structure for nodeunit tests with nested groups and setup/teardown
* functions. Run | nodeunit nodeunit_example.js | to see a printout of
* function names in the order that they are called. There aren't any actual
* tests here.
*/
process.env.NODE_ENV = 'test';
var testCase = require('nodeunit').testCase;
@icantrap
icantrap / git-proxy.sh
Created October 26, 2010 20:25
How to Github and Gitorious over HTTP proxy

You could always use Smart HTTP.

For read-only (git:) urls, install corkscrew.

  1. Download git-proxy.sh. Put it somewhere and make it executable.

  2. Run git config --global core.gitproxy '/usr/local/bin/git-proxy.sh'

To clone, push, pull over ssh, add the contents of ssh_config to your ~/.ssh/config file.

@cayblood
cayblood / polymer_setup.js
Last active January 17, 2019 13:33
Adding custom elements needs to wait until after polymer-ready
// 1. Load Polymer before any code that touches the DOM.
var script = document.createElement("script");
script.src = "/base/bower_components/webcomponentsjs/webcomponents.js";
document.getElementsByTagName("head")[0].appendChild(script);
// Delay Jasmine specs until WebComponentsReady
var POLYMER_READY = false;
beforeEach(function(done) {
window.addEventListener('polymer-ready', function () {
@umarov
umarov / index.ts
Created December 3, 2017 19:02
Polymer 3 with Webpack and TypeScript
import { OTUser, OTUserProvider, OTUserDetails } from './ot-user/ot-user'
import { OTFooter } from './ot-footer/ot-footer'
import { OTTopNav, OTTopNavSection, OTTopNavSubSection } from './ot-top-nav/ot-top-nav'
customElements.define('ot-user', OTUser)
customElements.define('ot-user-provider', OTUserProvider)
customElements.define('ot-user-details', OTUserDetails)
customElements.define('ot-footer', OTFooter)
@mnpenner
mnpenner / screenshot.js
Last active December 5, 2019 16:08
Save a screenshot with selenium-webdriver for JavaScript
var webdriver = require('selenium-webdriver');
var fs = require('fs');
var driver = new webdriver.Builder().build();
webdriver.WebDriver.prototype.saveScreenshot = function(filename) {
return driver.takeScreenshot().then(function(data) {
fs.writeFile(filename, data.replace(/^data:image\/png;base64,/,''), 'base64', function(err) {
if(err) throw err;
});
@anvk
anvk / deep_extend_javascript_objects.js
Last active September 19, 2020 04:01
Deep Extend for Javascript Objects (my polyfill for _.merge() function)
/* MIT license
* 2015 Alexey Novak
*
* Inspired by http://youmightnotneedjquery.com/ with few of my own modifications
*
**/
var deepExtend = function(out) {
out = out || {};
@gsainio
gsainio / gist:6322375
Created August 23, 2013 18:20
Sample perl code to use service accounts and oauth2 with Google's Admin SDK API.
#!/usr/public/bin/perl -w
use strict;
use JSON;
use JSON::WebToken;
use LWP::UserAgent;
use HTML::Entities;
my $private_key_string = q[-----BEGIN PRIVATE KEY-----
@springmeyer
springmeyer / create_index.js
Created August 10, 2011 23:41
create an sqlite rtree spatial index using node-sqlite3 and node-mapnik
/*
wget http://dl.dropbox.com/u/342088/10m-us-parks-area.sqlite
ogr2ogr -f SQLite parks.sqlite ParkPly_900913.shp
dane$ ogr2ogr -f SQLite parks.sqlite ~/Documents/MapBox/cache/2976a0c1-10m-us-parks-area/2976a0c1-10m-us-parks-area.shp
*/
@ebidel
ebidel / app.html
Last active May 1, 2021 15:42
Fast Polymer app loading - optimized for first render, progressively enhanced lazy loading
<!DOCTYPE html>
<html>
<head>
<style>
body.loading #splash {
opacity: 1;
}
#splash {
position: absolute;
top: 0;
@pahund
pahund / setup.js
Last active April 20, 2022 04:35
Using Chai and Jest assertions together with Jest's expect (thanks Ruben Oostinga!)
import chai from 'chai';
import sinonChai from 'sinon-chai';
import chaiAsPromised from 'chai-as-promised';
import chaiEnzyme from 'chai-enzyme';
chai.use(sinonChai);
chai.use(chaiAsPromised);
chai.use(chaiEnzyme());
// Make sure chai and jasmine ".not" play nice together