Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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
  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 / 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|
@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 / active_hack.rb
Created May 8, 2013 16:58
hack of activesupport dependencies when it won't load the file from the correct path /Users/<user_name>/.rvm/gems/jruby-1.7.3@<your_gemset>/gems/activesupport-3.2.13/lib/active_support/dependencies.rb
# fucking shit activesupport or rvm or whoever's fault it is
if file.include?('active_support/krypt')
puts ''
puts "changing include of file #{file} due to wrong path"
file.gsub!("/Users/#{user_name}/.rvm/gems/jruby-1.7.3/gems/activesupport-3.2.13/lib/active_support/",'')
puts "path changed to: #{file}"
puts ''
end
@williscool
williscool / some_mailer.rb
Last active December 16, 2015 20:29
Using a rails helper in a mailer or other class
class SomeMailer
class Helper
include ActionView::Helpers # rails standard helpers
include HelpfulMethodsHelper # for some function i_wrote
end
def helper
@@h ||= Helper.new
end
@williscool
williscool / post-commit
Created January 26, 2013 20:43
Git lab references post commit hook
#!/bin/sh
PRIVATE_TOKEN="YOU_SECRET_TOKEN"
GITLAB_URL="http://gitlab.example.com/"
URL=`git config --get remote.origin.url`
PROJECT=`basename ${URL} .git | cut -d':' -f2`
COMMIT_MSG="git log -1 HEAD"
COMMIT_HASH_MSG=`git log -1 HEAD | head -1`