Skip to content

Instantly share code, notes, and snippets.

app_id min max count sum inside_hour
mm/47048 0 1920 25038 25038 1
mp/01b6d919ffaf42bab0440b9d0108311b 1 1242 590 590 1
mp/710f154ce60549d4a0ecb0243ebfb2df 2 7 3 3 1
mp/702b29830f9348aaa9b588b518a3dbdf 14 22 8 8 1
mp/adcd2da60f9f4c4e9bdd6cc1ff6e42cb 4 736 54 54 1
mp/b0a95924c4664be791957cec0d18cb11 19 565 23 23 1
mp/7929d1a5c0964583a83795ffe81cebee 4 3401 2534 2534 1
mp/3ff5f42daa33422fb277622e65747a25 54 117 10 10 1
mp/a8ad165ba8ae4f838c89644cfa532ba0 3 3 2 2 1
@robbles
robbles / json_attribute.sql
Created March 7, 2016 19:43
Extract attribute from a JSON column with SQL
--
-- NOTE: this will just give you the original data if the attribute is not present.
-- You might need to wrap it in an IF somehow if it's not always there.
--
SELECT
substring_index(substring_index(TABLE.JSON_COLUMN, '"ATTRIBUTE_TO_EXTRACT": "', -1), '",', 1)
from TABLE.JSON_COLUMN
-- If the JSON data looks like this: {"key":"value"} instead of this: {"key": "value"} (no space after colon),
-- you'll need to use this slightly modified version:
@robbles
robbles / Makefile
Created December 22, 2015 01:54
Simple Makefile example for reference
# Find all files matching "src/*.go" and replace "src/%.go" with "bin/%"
OUTPUTS := $(patsubst src/%.go,bin/%,$(wildcard src/*.go))
# Reference all files to be built in a single rule
all: $(OUTPUTS)
# Rule for compiling a single output file in bin/
bin/%: src/%.go
# $* is replaced with the value of the wildcard in the rule (%)
go build -o bin/$* src/$*.go
def runserver(app, port=5000, profile_log=None):
"""Runs a development server."""
from werkzeug.serving import run_with_reloader
from werkzeug.debug import DebuggedApplication
from werkzeug.contrib.profiler import ProfilerMiddleware
app.debug = True
port = int(port)
#!/bin/bash
socat -d -d pty,raw,echo=0,link=/tmp/ttysA1 pty,raw,echo=0,link=/tmp/ttysB1 &
socat -d -d pty,raw,echo=0,link=/tmp/ttysA2 pty,raw,echo=0,link=/tmp/ttysB2 &
socat -d -d pty,raw,echo=0,link=/tmp/ttysA3 pty,raw,echo=0,link=/tmp/ttysB3 &
socat -d -d pty,raw,echo=0,link=/tmp/ttysA4 pty,raw,echo=0,link=/tmp/ttysB4 &
socat -d -d pty,raw,echo=0,link=/tmp/ttysA5 pty,raw,echo=0,link=/tmp/ttysB5 &
@robbles
robbles / signed_urls.js
Created July 5, 2013 01:17
HMAC signatures for API requests in different languages
var crypto = require('crypto');
var message = 'GET /foo/bar?arg1=aaaa&arg2=bbbb';
var secret = 'secret';
crypto.createHmac('sha256', secret).update(message).digest('base64');
// '82LHSJc4h/5BpLrBcGyWjTIiLuJTBYkgyGAb7cNmXew='
@robbles
robbles / connectSerialPorts.js
Created November 27, 2012 19:50
Create virtual serial ports that hold open an unreliable bluetooth connection with socat
#!/usr/bin/env node
var spawn = require('child_process').spawn;
var extname = require('path').extname;
// where to store the virtual ports while running
var virtual_port_dir = '/tmp/';
// socat displays this when successfully connected
var success_str = 'starting data transfer loop';
@robbles
robbles / jquery.fasttouch.js
Created August 20, 2012 06:20
jQuery plugin for accelerating "click" events on mobile browsers
/**
* Simple jQuery plugin that replaces $.click with a mobile-responsive version
* that doesn't break scrolling.
*/
(function($){
$.fn.extend({
clickTouch: function(handler) {
return this.each(function() {
var touchedWithoutScroll = false;
var self = $(this);
@robbles
robbles / gist:2795807
Created May 27, 2012 01:23
Rlwrap completion for node.js / JavaScript
require
global
process
console
log
error
warning
Buffer
__filename
__dirname
@robbles
robbles / virtualenv-auto-activate.sh
Last active November 7, 2023 14:01 — forked from codysoyland/virtualenv-auto-activate.sh
virtualenv-auto-activate with support for zsh and virtualenvwrapper
#!/bin/bash
# virtualenv-auto-activate.sh
#
# Installation:
# Add this line to your .bashrc or .bash-profile:
#
# source /path/to/virtualenv-auto-activate.sh
#
# Go to your project folder, run "virtualenv .venv", so your project folder
# has a .venv folder at the top level, next to your version control directory.