Skip to content

Instantly share code, notes, and snippets.

View mfo's full-sized avatar
💭
part time available for intersting projects

mfo mfo

💭
part time available for intersting projects
View GitHub Profile
@mfo
mfo / build.sh
Last active April 30, 2016 08:12
zopfli on snap-ci
# make zopfli
pushd .
git clone https://github.com/google/zopfli.git zopfli-build && cd zopfli-build && make
export PATH="$PATH:$(pwd)"
popd
# after assets precompile, zopfli all of them [nproc/sysctl -n hw.ncpu for compat btw centos & macox]
find public/assets | grep -E '.*\.(css|js)$' | xargs -P $(if [ $(which nproc) ]; then nproc; else sysctl -n hw.ncpu; fi;) zopfli
EventMachine::HttpRequest.use EventMachine::Middleware::JSONResponse
# prepare request
con = EventMachine::HttpRequest.new('https://stream.twitter.com/1.1/statuses/filter.json', {
connect_timeout: 0,
inactivity_timeout: 0,
keepalive: true
})
# plug oauth
con.use EventMachine::Middleware::OAuth({...keys..})
# setup tracking
@mfo
mfo / streaming_render_test.rb
Last active August 23, 2017 07:09
StreamingTemplateRenderer maybe cleaner
# frozen_string_literal: true
require "fiber"
module ActionView
# == TODO
#
# * Support streaming from child templates, partials and so on.
# * Rack::Cache needs to support streaming bodies
class StreamingTemplateRenderer < TemplateRenderer #:nodoc:
# Ruby fibers does not support Thread.current[:locals]