Skip to content

Instantly share code, notes, and snippets.

@kennberg
kennberg / cancel-stripe-subscriptions.js
Created May 3, 2016 21:13
Cancel all Stripe subscriptions
var STRIPE_SECRET_KEY = 'YOUR_KEY';
var OBJECTS_PER_REQUEST = 100;
var stripe = require('stripe')(STRIPE_SECRET_KEY);
function processSubs(err, subs) {
if (err) {
console.log(err);
return;
@kennberg
kennberg / sql
Last active August 29, 2015 14:17
MySQL Status, Database and Table Sizes
SHOW FULL PROCESSLIST;
SHOW ENGINE INNODB STATUS;
SELECT table_schema "db", SUM(data_length + index_length) / 1024 / 1024
"mb" FROM information_schema.TABLES GROUP BY table_schema ORDER BY mb DESC;
@kennberg
kennberg / gist:8553528
Last active January 4, 2016 02:09
Bookmarklet that injects jQuery into the page, so jQuery can be used right inside the Chrome Development Tools > Console until you refresh or change the tab.
javascript:(function(){d=document;jq=d.createElement('script');jq.src ="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";d.getElementsByTagName('head')[0].appendChild(jq);setTimeout(function(){jQuery.noConflict();},1000);})()
@kennberg
kennberg / NumberFormat.soy
Last active January 2, 2016 20:49
Google closure template for formatting numbers.
/**
* Format number (integer).
* @param n
*/
{template .formatNumber}
{let $x: floor($n) /}
{if $x >= 1000 and $x < 1000000000}
{if $x < 1000000}
{floor($x / 1000)},
{else}
@kennberg
kennberg / .bashrc
Created June 4, 2013 06:34
Bash script to generate MY_UUID for Pebble app and copy it into clipboard.
# Pebble UUID generator
function pebble_uuid {
uuid_string=`uuidgen | sed "s/-//g"`
uuid="#define MY_UUID {"
for i in {0..15}; do
if [ $i -ne 0 ]; then
uuid="$uuid,"
fi
uuid="$uuid 0x${uuid_string:$[i*2]:2}"
done
void writeBuffer(char *pPath, uint8_t *pBuffer, int width, int height, int channels) {
int x, y, j, c;
FILE *p = fopen(pPath, "wb");
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
for (c = 0; c < channels; c++) {
uint8_t buf[1];
j = (y * width + x) * channels + c;
buf[0] = pBuffer[j];
fwrite(buf, 1, sizeof(buf), p);