Skip to content

Instantly share code, notes, and snippets.

@amichal
amichal / .gitignore
Last active October 24, 2017 21:40
for eg
tmp/**
@amichal
amichal / serializer_benchmarks.rb
Created May 10, 2017 17:05 — forked from aishfenton/serializer_benchmarks.rb
Performance comparison of different ruby serializer methods
# sudo gem install bson
# sudo gem install bson_ext
# sudo gem install yajl-ruby
# sudo gem install json
# sudo gem install msgpack
require 'rubygems'
require 'benchmark'
require 'yaml'
require 'bson'
@amichal
amichal / application_controller.rb
Last active March 27, 2017 18:46
Server-side Google Analytics tracking in rails
class ApplicationController
around_filter :track_with_google_analytics
private def track_with_google_analytics
start = Time.now
yield
# Track API hits server-side using Google's Measurement Protocol
# https://developers.google.com/analytics/devguides/collection/protocol/v1/
if ENV['GA_TRACKING_CODE'].present?
finish = Time.now
gem 'lograge'
before_filter do
if request.user_agent =~ /bingbot/
render :status => 503, :text=>'Too busy to server spiders now'
return false
end
end
<?php
$survey = array(
'Q0' => array(
'number' => false,
'prompt' => 'Email Address:',
'type' => 'email',
'input_attribs' => 'type="email" placeholder="e.g. [email protected]" required autofocus'
),
'Q1' => array(
@amichal
amichal / select2_input.rb
Created May 6, 2013 17:20
select2 integration with simple_form
class Select2Input < SimpleForm::Inputs::CollectionSelectInput
def input
options[:include_hidden] ||= false
options[:include_blanks] ||= false
options[:input_html][:id] ||= "#{@builder.options[:as]}_#{attribute_name}"
dom_selector = "##{options[:input_html][:id]}"
if select2_options = options.delete(:select2)
options[:collection] = [] + Array(@builder.object.send(attribute_name))
end
#asset pipeline on
config.assets.enabled = true
#dont load the whole damn app and connect to the db to precompile
config.assets.initialize_on_precompile = false
# turn off compression entirely
config.assets.compress = false
#OR for css/js explicitly
@amichal
amichal / README
Created September 26, 2012 15:24
GitHub Tweaks
To use on OSX:
1.allow extension installs from github
$defaults write com.google.Chrome ExtensionInstallSources -array "https://*.github.com/*"
2. restart Chrome
3. come back here and click the 'raw' link for github_gr.user.js
4. allow Chrome to install the script above as a user extension
5. go to github issues list.
/*
drawDial(
value:
renderTo:
)
*/
function drawDial(options) {
var renderTo = options.renderTo,
value = options.value,