Skip to content

Instantly share code, notes, and snippets.

View emischorr's full-sized avatar

Enrico Mischorr emischorr

View GitHub Profile
@emischorr
emischorr / actionTimingMiddleware.js
Last active February 24, 2019 12:17
Middleware to tie Redux actions to the React user timing API
export default () => (next) => (action) => {
if (performance.mark === undefined) return next(action)
performance.mark(`${action.type}_start`)
const result = next(action)
performance.mark(`${action.type}_end`)
performance.measure(
`${action.type}`,
`${action.type}_start`,
`${action.type}_end`
)
@emischorr
emischorr / gist:51c75342fc5521356a52450bed79996e
Created September 5, 2017 14:22
Change postgres default template0 to UTF8
psql -U postgres
#> update pg_database set datallowconn = TRUE where datname = 'template0';
#> \c template0
#> update pg_database set datistemplate = FALSE where datname = 'template1';
#> drop database template1;
#> create database template1 with template = template0 encoding = 'UTF8';
#> update pg_database set datistemplate = TRUE where datname = 'template1';
#> \c template1
#> update pg_database set datallowconn = FALSE where datname = 'template0';
@emischorr
emischorr / remote_speaker
Created January 28, 2013 08:46
Play local microphone on remote machine's speakers. Uses sox.
rec -t wav - | ssh user@remotehost play -t wav
@emischorr
emischorr / app.rb
Created July 26, 2012 09:06 — forked from dunedain289/app.rb
A fast sinatra redis data viewer
require 'rubygems'
require 'haml'
require 'sinatra'
require 'redis'
helpers do
def redis
@redis ||= Redis.connect
end
end
@emischorr
emischorr / compass-retina-sprites.scss
Created April 16, 2012 08:48 — forked from thulstrup/compass-retina-sprites.scss
Using Compass to generate normal and retina sprite maps
$sprites: sprite-map("sprites/*.png");
$sprites-retina: sprite-map("sprites-retina/*.png");
@mixin sprite-background($name) {
background-image: sprite-url($sprites);
background-position: sprite-position($sprites, $name);
background-repeat: no-repeat;
display: block;
height: image-height(sprite-file($sprites, $name));
width: image-width(sprite-file($sprites, $name));
@emischorr
emischorr / campirc.rb
Created April 11, 2012 19:45 — forked from rkh/campirc.rb
IRC <-> Campfire bridge
# coding: binary
# IRC <-> Campfire bridge, set IRC password to SUBDOMAIN:TOKEN and connect to localhost:6667
# Remove special chars/spaces from channel names (ie "Foo Bar" becomes #FooBar). Only tested with LimeChat.
# gem install excon && gem install yajl-ruby -v "< 2.0"
%w[socket thread uri excon yajl yajl/http_stream].each { |lib| require lib }
Thread.abort_on_exception = true
[:INT, :TERM].each { |sig| trap(sig) { exit } }
server = TCPServer.new('127.0.0.1', 6667)
loop do
@emischorr
emischorr / gist:2361835
Created April 11, 2012 19:44 — forked from dhh/gist:1975644
Rails mass assignment protection
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private