Skip to content

Instantly share code, notes, and snippets.

@williscool
williscool / gist:5798143
Created June 17, 2013 16:16
Mad Links about stuff
How Selections Work
http://bost.ocks.org/mike/selection/
Annotated ES5
http://es5.github.io/#introduction
requestAnimationFrame for smart animating - Paul Irish
http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/
Unreal JavaScript | Hacker News
@williscool
williscool / generate_payment_report.rb
Last active August 29, 2015 14:02
Get payment history of specific client from harvest
require 'harvested'
harvest = Harvest.hardy_client(subdomain: 'YOUR_SUBDOMAIN', username: 'YOUR_USERNAME_OR_EMAIL', password: 'YOUR_PASSWORD')
specific_client = harvest.clients.all.select{|c| c.name == 'specific_client'}.first
all_invoices = harvest.invoices.all
invoices = all_invoices.select{|i| i.client_id = specific_client.id}
jaged_payments = invoices.collect{|i| harvest.invoice_payments.all(i) } # call takes a second. grab a cup of tea. and/or add some logging.
all_payments = jaged_payments.flatten
require 'active_support/all'
#csv_string = CSV.generate do |csv|
  1. install node
  2. install npm if you have to and npm init
  3. npm install express --global --save
  • global makes the files go to a global dir on your comp instead of in the repo
  • save adds it as a dep to your package.json (the functional equivalent of a Gemfile for node.js apps)
  1. have an express app that will just serve assets
  • it serves stuff in the public dir that is where out app will be
  • index.html is a convention that lets the server know that if a person hits the root of a url server this html
  1. add bower (because it will get alot of assets and stuff for us)
  • npm install bower --global
@williscool
williscool / gist:f2a663a4e5c2da847d2a
Created August 4, 2014 01:46
ng view and routing tutorial.md
  1. do ngview
  • bower install angular-route --save
  • we use the name views for the folder in this example but you could call it whatever you want. some people like to organize their code into feature but for this examples we will just toss all views in the views folder stock rails style.
  • (only if someone ask) unfortunately you can only set one view with ngView. it gets more complicated if you want multiple
  1. intro providers
  • Providers are objects that provide (create) instances of services and expose configuration APIs that can be used to control the creation and runtime behavior of a service. In case of the $route service, the $routeProvider exposes APIs that allow you to define routes for your application.
  1. add another page
  2. add variable urls and display them in page
  • intro routeParams
@williscool
williscool / AppStart.java
Created December 11, 2014 01:45
AppStart - Check if started for the first time Android
/**
* Distinguishes different kinds of app starts: <li>
* <ul>
* First start ever ({@link #FIRST_TIME})
* </ul>
* <ul>
* First start in this version ({@link #FIRST_TIME_VERSION})
* </ul>
* <ul>
* Normal app start ({@link #NORMAL})
@williscool
williscool / referralsaasquatch_node.js
Created February 12, 2015 08:19
referralsaasquatch node.js integration
// this relies or lodash or underscore
// based on algorithm here http://docs.referralsaasquatch.com/squatchjs/signed-requests
var params = req.body;
// delete any null keys http://stackoverflow.com/questions/14058193/remove-empty-properties-falsy-values-from-object-with-underscore-js
var clean_params = _.pick(params, _.identity);
// sort keys and join to add to string
var params_to_sign_string = '' ;
@williscool
williscool / Super Simple Ngnix Cors Proxy
Last active August 29, 2015 14:16
Not as simple as I thought it was at first. (you want to skip out fast if its an options request. and you want to make sure allow creds and methods and origin is set all the time)
server {
listen 80;
server_name yourserver.com;
#
# A CORS (Cross-Origin Resouce Sharing) config for nginx
#
# == Purpose
#
@williscool
williscool / permutations.js
Last active January 21, 2017 04:42 — forked from md2perpe/permutations.js
Function for generating permutations of a list.
// permutations(["c","a","t"])
function permutations(array){
if (array.length === 0) return [[]];
var perms = [];
for(var i = 0; i < array.length; i++) {
var copy = array.slice(0);
@williscool
williscool / cloudSettings
Last active January 19, 2021 06:56
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-01-19T06:56:32.553Z","extensionVersion":"v3.4.3"}
@williscool
williscool / journey-note-to-csv.js
Last active June 6, 2017 05:43
Journey Note Json To Csv
const fs = require('fs');
const glob = require('glob');
const json2csv = require('json2csv');
const options = {};
glob("*.json", options, function (er, files) {
// files is an array of filenames.
// If the `nonull` option is set, and nothing
// was found, then files is ["**/*.js"]