Skip to content

Instantly share code, notes, and snippets.

Chris Le chrisle

Block or report user

Report or block chrisle

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
chrisle / gist:2252209
Created Mar 30, 2012
CURL as GoogleBot 2.1
View gist:2252209
curl --user-agent "Googlebot/2.1 (+" -v $@
chrisle / hashes.js
Last active Aug 29, 2019
Compute hashes for Google Docs
View hashes.js
function computeMD5(str) {
var digest = Utilities.computeDigest(Utilities.DigestAlgorithm.MD5, str);
return Utilities.base64Encode(digest);
function computeSHA1(str) {
var digest = Utilities.computeDigest(Utilities.DigestAlgorithm.SHA_1, str);
return Utilities.base64Encode(digest);
chrisle / simple_google_analytics.rb
Last active Aug 1, 2019
My simple Google Analytics API export API. Exports GA data as an array of flattened hashes with a SHA1 signature. No DSL, no sugar.
View simple_google_analytics.rb
require 'digest'
# = simple_google_analytics.rb
# Chris Le <chris at iamchrisle dot com>
# This module is an wrapper to export data from Google Analytics as a flattened
# hash suitable for database storage. It does not require any other gems other
# than 'oauth'. I used this simply to get metrics and directly store them in
# a database.
View answer.js
* To answer @AnnieCushing's question on Twitter:
* Author: Chris Le - @iamchrisle
* There's a few ways to do this.
* - Like @SimoAhava suggested, server redirects that strips parameters if you
* have the ability to control the server.
chrisle / gist:4206925
Created Dec 4, 2012
newspaper to seomoz
View gist:4206925
require 'mechanize'
require 'linkscape'
agent =
agent.user_agent_alias = 'Mac Safari'
# Put your state here
state = "PA"
page = agent.get "{state}"
chrisle / scraper.js
Last active Jul 2, 2016
Scrape Billboard Hot 100 and create an array of objects
View scraper.js
* Install x-ray with: 'npm install x-ray'
* (Also see:
* Run with: node scraper.js
* Result:
* [ { rankCurrent: '1',
* rankLast: 'Last Week: 1',
chrisle / gist:8588282
Created Jan 23, 2014
TLDR - Google Analytics
View gist:8588282
* The very simplest explanation of how GA works in JavaScript is that it's simply an array.
* The GA tag (not the new Universal tag) looks similar to this:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-y']);
(function () {
chrisle / gist:7055839
Last active Dec 25, 2015
Should an API allow for polling or instead push results? What do you prefer?
View gist:7055839


If http://localhost/api/do_job kicks off a job on the backend that will take 45-120 seconds to complete, what should the API return?

POLL) Return 202 Accepted + a URL polling end point.


202 Accepted
{ "job_id": 103859195, "poll": "http://localhost/poll/103859195", "complete": "0%" }
chrisle / gist:6368604
Created Aug 28, 2013
Humanize an underscored or camel cased string in JavaScript
View gist:6368604
* Humanize a string. Turns underscored or camel cased string into human readable strings
* @example
* TextUtils.humanize( 'keyword_category' ); // => "Keyword Category"
* TextUtils.humanize( 'keywordCategory' ); // => "Keyword Category"
* @return {String}
humanize: function(str) {
View gist:5774203
class Puzzle
attr_accessor :field
def initialize
self.field = true
def run
puts field.inspect # => true
You can’t perform that action at this time.