Skip to content

Instantly share code, notes, and snippets.

View thom4parisot's full-sized avatar

Thomas Parisot thom4parisot

View GitHub Profile
@thom4parisot
thom4parisot / anonymous-quora.js
Created August 3, 2012 21:40
Navigating Quora without being logged in
Array.prototype.forEach.call(document.querySelectorAll('[class*="blurred_answer"]'), function(el){ el.className = el.className.replace(/blurred_answer[^\s]*/g, '') })
@thom4parisot
thom4parisot / freshbooks-invoice-total-hours.js
Created October 18, 2012 07:30
Freshbooks Invoice Total Hours
$('.invbody-items:first tbody tr').map(function(){
return parseInt($(this).find('td:eq(3)').text().trim(), 10);
}).get().reduce(function(left, right){
return (left || 0) + (right || 0);
}); // total hours as a number
@thom4parisot
thom4parisot / update-route53-dns.sh
Created November 15, 2012 11:49 — forked from dfox/update-route53-dns.sh
A script to update DNS on Route 53
#!/bin/sh
# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Load configuration
. /etc/route53/config
@thom4parisot
thom4parisot / refine-restaurants-cleanup.json
Created December 3, 2012 15:23
DataLocale Restaurants — OpenRefine + ElasticSearch Export
[
{
"op": "core/column-removal",
"description": "Remove column Adresse suite",
"columnName": "Adresse suite"
},
{
"op": "core/text-transform",
"description": "Text transform on cells in column Site web using expression grel:if(isNonBlank(value), 'http://'+replace(value, /^https?:\\/\\//, ''), null)",
"engineConfig": {
@thom4parisot
thom4parisot / refine-domains-cleanup.json
Created December 3, 2012 15:27
DataLocale Wine Domains — OpenRefine + ElasticSearch Export
[
{
"op": "core/column-removal",
"description": "Remove column Types de produits",
"columnName": "Types de produits"
},
{
"op": "core/text-transform",
"description": "Text transform on cells in column Adresse using expression grel:if (isNonBlank(cells[\"Adresse suite\"].value), join([value, cells[\"Adresse suite\"].value], \"\\n\"), value)",
"engineConfig": {
@thom4parisot
thom4parisot / refine-hosting-cleanup.json
Created December 3, 2012 15:28
DataLocale Hosting — OpenRefine + ElasticSearch Export
[
{
"op": "core/column-removal",
"description": "Remove column File",
"columnName": "File"
},
{
"op": "core/text-transform",
"description": "Text transform on cells in column Adresse using expression grel:if (isNonBlank(cells[\"Adresse suite\"].value), join([value, cells[\"Adresse suite\"].value], \"\\n\"), value)",
"engineConfig": {
@thom4parisot
thom4parisot / gist:4240294
Created December 8, 2012 13:36
Game of Life in Clojure
(defstruct cell :x :y :state)
(defstruct state :state)
(def state-alive (struct state "alive"))
(def state-dead (struct state "dead"))
(def cell1 (struct cell 13 37 state-alive))
(def grille [(struct cell 13 37 state-alive) (struct cell 13 38 state-alive) (struct cell 14 37 state-alive)])
@thom4parisot
thom4parisot / http-response
Created January 7, 2013 09:28
Trying to figure out why these headers still imply an HTTP call for this same URL. First call: expecting a prime cache (nothing). Second call: not expected, the browser uses the cached version.
HTTP/1.1 200 OK
Date: Mon, 07 Jan 2013 09:26:17 GMT
Server: Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r
X-Robots-Tag: noindex
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Expires: Thu, 17 Jan 2013 09:26:17 GMT
Pragma: public
Max-Age: 864000
Cache-Control: s-max-age: 1800, max-age: 864000
@thom4parisot
thom4parisot / gist:4555312
Last active December 11, 2015 05:49
Google Apps Scripts OAuth use case with Tumblr. Run the `startTumblrAuthorization` and follow the authorization workflow.
function getTumblrOAuthConfig_(){
// values available once an app is registered here: http://www.tumblr.com/oauth/apps
// registered app callback URL should be: https://script.google.com/macros
var consumer_key = "<OAuth Consumer Key>";
var consumer_secret = "<Secret Key>";
var oAuthConfig = UrlFetchApp.addOAuthService("Tumblr");
oAuthConfig.setAccessTokenUrl('http://www.tumblr.com/oauth/access_token');
oAuthConfig.setAuthorizationUrl('http://www.tumblr.com/oauth/authorize');
Array.prototype.slice.map(document.querySelectorAll('a[href]'), function(el){
return { "href": el.href, "rel": el.rel || null };
});