Skip to content

Instantly share code, notes, and snippets.

@danromero
danromero / find_last_name
Created February 12, 2014 17:41
Excel/Numbers formula for finding a last name
=RIGHT(A2,LEN(A2)-FIND(" ",A2))
@danromero
danromero / highlight_table_class.js
Created January 28, 2014 22:30
Highlight HTML table cells based on class and value (uses Bootstrap 3 tr/td class stylings)
$("td.days").each(function() {
$this = $(this)
var value = $this.html();
if (value<2) { $this.addClass('success');}
else if (value<5) { $this.addClass('warning');}
else { $this.addClass('danger');}
});
@danromero
danromero / hipchat_v2_private_message_curl
Created January 22, 2014 20:59
HipChat API v2 private message via curl
curl -H "Content-Type: application/json" \
-X POST \
-d "{\"message\": \"hello\" }" \
https://api.hipchat.com/v2/user/433057/message?auth_token=4gZZzsXQY75pZHhfnnujKHT8F101LWzcwGPu4jUV
@danromero
danromero / dev.sh
Created January 14, 2014 19:19
Dev bash script—changes from home directory to project directory, pulls latest version of master, boots up vagrant image
#! /bin/bash
cd envoy-web/
git pull
vagrant up
vagrant ssh
@danromero
danromero / stripe_last_10_successful_charges.erb
Last active December 29, 2015 09:59
Display last 10 successful charges in a Stripe account.
<ul>
<% Stripe::Event.all(:type => "charge.succeeded").each do |stripe_event| %>
<li><%= Stripe::Customer.retrieve(stripe_event.data.object.customer).description %></li>
<li><%= number_to_currency(stripe_event.data.object.amount / 100.00) %></li>
<% end %>
</ul>
@danromero
danromero / Heroku-Postgres-to-local-Postgres-to-pandas
Last active December 27, 2015 15:39
Commands to sanitize and import a Heroku Postgres dump into Postgres.app on a Mac
pg_restore dumpfile >plaintext.sql
iconv -c -f UTF-8 -t UTF-8 <plaintext.sql >plaintext-cleaned.sql
psql dbname < plaintext-cleaned.sql
COPY table TO 'data.csv' DELIMITER ',' CSV HEADER;
@danromero
danromero / Gmail-Inbox-to-Spreadsheet
Created November 6, 2013 18:27
Simple Gmail inbox to spreadsheet script. Useful for running pivots on "Contact Us"-type emails (e.g. [email protected]).
function processInbox() {
// get all threads in inbox
var threads = GmailApp.getInboxThreads();
for (var i = 0; i < threads.length; i++) {
// get current active Google Docs spreadsheet
var sheet = SpreadsheetApp.getActiveSheet();
// get subject, to, from and date of 1st message in thread
sheet.appendRow([threads[i].getMessages()[0].getSubject(), threads[i].getMessages()[0].getTo(), threads[i].getMessages()[0].getFrom(), threads[i].getMessages()[0].getDate()]);
Utilities.sleep(1000);
}