Skip to content

Instantly share code, notes, and snippets.

10x Ninja Rockstar

Adam Loving adamloving

10x Ninja Rockstar
Block or report user

Report or block adamloving

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
adamloving / gmail-bulk-delete.js
Last active Aug 29, 2015
Delete a bunch of emails (thousands) by tag from gmail
View gmail-bulk-delete.js
function batchDelete() {
var batchSize = 10; // Process up to 10 threads at once
for (i = 175; i > 0; i--) {
var threads ='label:outbound older_than:' + i + 'd');
for (j = 0; j < threads.length; j += batchSize) {
GmailApp.moveThreadsToTrash(threads.slice(j, j+batchSize));
// Logger.log('finished move %d', j);
adamloving /
Created Apr 23, 2014
How to find your shit

Where is apache?

$ which apachectl

It's not a symlink, so it must be mac version! Where's the confthing?

$ apachectl -V | grep conf

Where's PHP?

adamloving /
Last active Aug 29, 2015
This gist defines "severity" and "priority" as they relate to prioritizing bugs to be fixed.

Separating severity from priority is useful in prioritizing bugs. At the end of the day, priority is all that matters - but severity helps clarify how "bad" the bug is.

Basically, it comes down to...

  • SnP1 = hotfix (where n is any number)
  • SnP2 = in this sprint
  • SnP3 = later (maybe never)

... but almost always, high severity bugs will have a high priority.

adamloving /
Last active Aug 29, 2015
Writing clean code with a callback pattern vs. deferreds.


  1. Only nest the simplest of functions
  2. Give functions a name
  3. Seems weird to pass callback function as an argument

The callback way

adamloving /
Last active Aug 29, 2015
Node.js hosting best practices. How to host node in production.

Hosting Node.js

We need to host node ourselves (Rackspace server) to have access to the file system (temp files for image processing) and (legacy) local database.

Have you hosted node in production? If so, what was the web server setup? Currently, we're using nginx + a unix socket file + forever or upstart. My inclination is to stop hosting it ourselves and go for a PaaS (like heroku) - but that's because I wish this stuff was not my problem. What I'm looking for is a clear recipe for best practices.


Hosting node is hard because unhandled errors force the node.js v8 process to die and need a restart.

adamloving / auto-fbpost.rb
Created May 26, 2014
Post several links to a Facebookpage
View auto-fbpost.rb
#!/usr/bin/env ruby
# foreman run script/social/auto-fbpost.rb data/crawl-data.json
# To get page access token, go to graph explorer, get user token with manage_pages and publish_actions permission,
# then request /{userId}/accounts
require 'koala'
require 'json'
urls = JSON.parse(
adamloving / auto-twitter-post.rb
Created May 26, 2014
Post several links to twitter feed
View auto-twitter-post.rb
#!/usr/bin/env ruby
# foreman run script/social/auto-tweet.rb data/crawl-data.json
require 'Twitter'
require 'json'
client = do |config|
config.consumer_key = ENV['TWITTER_API_KEY']
config.consumer_secret = ENV['TWITTER_API_SECRET']
config.access_token = ENV['TWITTER_ACCESS_TOKEN']
config.access_token_secret = ENV['TWITTER_ACCESS_TOKEN_SECRET']
adamloving / array-reference.php
Created May 30, 2014
Daily PHP WTF. Adding a key to an array creates a new and different array.
View array-reference.php
$a = array();
$b = $a;
// "When using the identity operator (===), object variables are identical
// if and only if they refer to the same instance of the same class."
if ($a === $b) print "same\n";
$a['test'] = 'something';
adamloving / coffee-map-hack.js
Created Jun 30, 2014
Compile coffee script with source map at require time.
View coffee-map-hack.js
var CoffeeScript = require('coffee-script')
// CoffeeScript.register()
function requireCoffeeScript(relativePath) {
var path = require('path');
var fs = require('fs');
relativePath = path.resolve(__dirname, relativePath);
console.log('relativePath', relativePath);
adamloving /
Created Aug 10, 2014
fetch (verify) a minecraft profile
curl -d '{"name":"notch","agent":"minecraft"}' -H 'Content-Type: application/json'
#<USERNAME>.png for skin
You can’t perform that action at this time.