Skip to content

Instantly share code, notes, and snippets.

probably partying...

Chris Le chrisle

probably partying...
View GitHub Profile
chrisle / hashes.js
Last active May 6, 2020
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 / nico.js
Created Feb 11, 2013
Nicos bookmarklet
View nico.js
// This is to be used as a bookmarklet
// Supposed to show a prompt where you pick if you want to do a site: search alpha using 'a' or bravo using 'b'
// However, this isn't working as a bookmarklet but does work in the live w3 editor
javascript:var name=prompt("Please enter your name \n a = alpha \n b = bravo","x");
switch (name) {
case "a":
location.href=''+document.domain.replace('www.','')+" alpha"
case "b":
View user_engagement_1.js
<form id="myForm">
Name: <input type="text" name="name" id="name" /><br/>
Email: <input type="text" name="email" id="email" /><br/>
Password: <input type="text" name="password" id="password" /><br/>
Website: <input type="text" name="website" id="website" /><br/>
<button type="submit" onClick="trackUserEngagement('myForm');">Submit</button>
<script type="text/javascript">
// Track user engagement on a form
chrisle / simple_google_analytics.rb
Last active Apr 12, 2020
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 escaped_fragment.rb
# Looks for the escaped fragment meta tag. If found, gets the HTML snapshot
# instead
module GoogleBotSimulator::EscapedFragment
def has_meta_fragment?
('//meta[@name="fragment"]/@content').to_s == '!') ? true : false
def url_with_escaped_fragment(url)
View capybara_with_phantom_js.rb
module CapybaraWithPhantomJs
include Capybara
# Create a new PhantomJS session in Capybara
def new_session
# Register PhantomJS (aka poltergeist) as the driver to use
Capybara.register_driver :poltergeist do |app|
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 / csv_writer.rb
Created Nov 2, 2012
JSON > CSV > data_miner > database
View csv_writer.rb
# Converts JSON data into CSV and writes to a temporary CSV file
require 'ruport'
# see ruport_19.rb
require 'monkey_patches/ruport_19'
class CsvWriter
# Initialize an instance of CsvWriter
def initialize
chrisle /
Created Aug 14, 2012
Facebook Likes for Excel using DataNitro
""" Facebook likes for Excel using DataNitro
import urllib2
import json
def facebook_likes(url):
facebook_url = "" + url
raw_data = urllib2.urlopen(facebook_url).read()
chrisle / gist:2785524
Created May 25, 2012
Curl as ImportXML
View gist:2785524
curl --user-agent "-" $@
You can’t perform that action at this time.