Stephan Schubert jazen

View 1.9.3-p484-railsexpress.md

ruby-1.9.3-p484 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p484 with the railsexpress patchsets: https://github.com/skaes/rvm-patchsets

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

View mysql_ramdisk_osx.sh
1 2 3 4 5 6 7 8 9 10
diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://2048000`
 
/usr/local/Cellar/mysql/5.6.15/scripts/mysql_install_db \
--basedir=/usr/local/Cellar/mysql/5.6.15 \
--datadir=/Volumes/ramdisk
 
/usr/local/Cellar/mysql/5.6.15/bin/mysqld \
--basedir=/usr/local/Cellar/mysql/5.6.15 \
--datadir=/Volumes/ramdisk \
--plugin-dir=/usr/local/Cellar/mysql/5.6.15/lib/plugin \
View 1.9.3-p484-railsexpress.md

ruby-1.9.3-p484 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p484 with the railsexpress patchsets: https://github.com/skaes/rvm-patchsets

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

View share_counts.md

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

View jquery-plugin-template.js
1 2 3 4 5 6 7 8 9 10
/*!
* jQuery lightweight plugin boilerplate
* Original author: @ajpiano
* Further changes, comments: @addyosmani
* Licensed under the MIT license
*/
 
// the semi-colon before the function invocation is a safety
// net against concatenated scripts and/or other plugins
// that are not closed properly.
View multi_fetch.rb
1 2 3 4 5 6 7 8 9 10
# Usage:
#
# h = { a: 1, b: 2 }
#
# h.multi_fetch(:a) # => [1]
# h.multi_fetch(:a, :b) # => [1, 2]
# h.multi_fetch(:a, :c) # => [1, nil]
# h.multi_fetch(a: 1, c: 3) # => [1, 3]
 
class Hash
View using.rb
1 2 3 4 5
def using(klass)
Module.constants.find_all do |name|
klass > Object.const_get(name) if name != name.upcase
end
end
View profile.rb
1 2 3 4 5 6 7 8 9
def profile(prefix = "profile")
result = RubyProf.profile { yield }
 
dir = File.join(Rails.root, "tmp", "performance", params[:controller].parameterize
FileUtils.mkdir_p(dir)
file = File.join(dir, "callgrind.%s.%s.%s" % [prefix.parameterize, params[:action].parameterize, Time.now.to_s.parameterize] )
open(file, "w") { |f| RubyProf::CallTreePrinter.new(result).print(f, :min_percent => 1) }
end
View install_mysql2_gem_on_osx.sh
1 2 3 4 5 6
# Assumes you're using homebrew.
# Adjust the version to your convenience.
 
env ARCHFLAGS="-Os -g -fno-strict-aliasing -arch x86_64" gem install mysql2 -v '0.3.15' -- \
--with-mysql-include=/usr/local/Cellar/mysql/5.6.15/include \
--with-mysql-config=/usr/local/Cellar/mysql/5.6.15/bin/mysql_config
View active_data.js.coffee
1 2 3 4 5 6 7 8 9 10
do ($ = jQuery, exports = window) ->
 
class ActiveDataBinder
constructor: (uid) ->
 
# Use a jQuery object as simple PubSub
 
pubSub = $ {}
 
# We expect a 'data' attribute specifying the binding
Something went wrong with that request. Please try again.