Skip to content

Instantly share code, notes, and snippets.

View jschairb's full-sized avatar

Josh Schairbaum jschairb

View GitHub Profile
@jschairb
jschairb / estabs.py
Created November 9, 2017 15:39
Chrome tabs to JSON structure
# -*- coding: utf-8 -*-
#!/usr/bin/env python
import hashlib
import json
import re
import subprocess
import sys
from time import gmtime, strftime
'use strict'
// Slack's Realtime Messaging Client
const RtmClient = require('@slack/client').RtmClient;
const MemoryDataStore = require('@slack/client').MemoryDataStore;
// Slack's event name constants
const RTM_EVENTS = require('@slack/client').RTM_EVENTS;
const CLIENT_EVENTS = require('@slack/client').CLIENT_EVENTS;
def some_method
do_something
rescue SomethingError
raise SomeMethodErroredError
end
error SomeMethodErroredError do
[422, headers, body]
end
@jschairb
jschairb / faraday_request_opts.rb
Created February 27, 2015 15:58
Setting request options for all requests from a Faraday client
require 'faraday'
require 'patron'
request_url = 'https://example.com'
options = {
:headers => {
"Accept" => "application/json"
},
:request => {
sudo modprobe spi-bcm2708
sudo modprobe fbtft_device name=adafruitts rotate=90
export FRAMEBUFFER=/dev/fb1
startx
@jschairb
jschairb / primitive_access.rb
Created July 8, 2014 15:25
Dual-access of objects that replace primitive data structure
require 'logger'
module PrimitiveAccess
def self.included(base)
base.send(:include, InstanceMethods)
end
module InstanceMethods
def primitive_logger
@logger ||= Logger.new(STDOUT)
@jschairb
jschairb / lager.rb
Created May 19, 2014 03:02
Messing around w/ some metric logging
require 'logger'
require 'json'
class LagerFormatter < Logger::Formatter
def self.call(severity, time, prg_name, message)
defaults = {
:severity => severity,
:time => time,

Keybase proof

I hereby claim:

  • I am jschairb on github.
  • I am jschairb (https://keybase.io/jschairb) on keybase.
  • I have a public key whose fingerprint is 619E C489 AF13 56B9 FB95 F56C B766 5248 E14C 9F96

To claim this, I am signing this object:

@jschairb
jschairb / method_proxy.rb
Created August 10, 2013 04:25
a method proxy
def output(*args)
end
class AttributeAccessor < Module
def initialize(*names)
@_names = names
end
def included(model)
super
@_names.each { |n| attr_accessor n }
end
end