Skip to content

Instantly share code, notes, and snippets.

Michael Koper michaelkoper

  • Nusii
  • Madrid
Block or report user

Report or block michaelkoper

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
seyhunak /
Last active Oct 20, 2017
Rails - Apache Bench - Load Testing (if Devise Sign-in Required)
curl --cookie-jar cookie_file $LOGIN_PAGE | grep csrf-token
<meta content="csrf-token" name="csrf-token" />
ssimeonov / array_validator.rb
Last active May 29, 2019
Enumerable and array validators for ActiveModel::Validations in Rails. Especially useful with document-oriented databases such as MongoDB (accessed via an ODM framework such as Mongoid).
View array_validator.rb
# Syntax sugar
class ArrayValidator < EnumValidator
michaelkoper / gist:4772413
Last active Dec 12, 2015
Some handy media queries for mobile devices
View gist:4772413
@mixin mobile
@media (min-device-width: 320px) and (max-device-width: 568px)
@mixin mobile-portrait
@media (min-device-width: 320px) and (max-device-width: 568px) and (orientation:portrait)
@mixin mobile-landscape
@media (min-device-width: 320px) and (max-device-width: 568px) and (orientation:landscape)
beakr / gist:2688904
Created May 13, 2012
Custom fonts in Rubymotion
View gist:2688904
# Rakefile
Motion::Project::App.setup do |app|
# Use `rake config' to see complete project settings. = 'helloapp'
app.fonts = ['consolas.ttf']
# Put consolas.ttf in resources/
bogdanconstantinescu / application.rb
Created May 9, 2012 — forked from t2/application.rb
Formatting Rails form elements for Twitter Bootstrap error validation
View application.rb
ActionView::Base.field_error_proc = do |html_tag, instance|
html = %(<div class="field_with_errors">#{html_tag}</div>).html_safe
# add nokogiri gem to Gemfile
form_fields = [
kconragan /
Last active Oct 9, 2019
Enable key repeat in Apple Lion for Sublime Text in Vim mode
# Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key
# that enables you to choose a character from a menu of options. If you are on Lion
# try it by pressing and holding down 'e' in any app that uses the default NSTextField
# for input.
# It's a nice feature and continues the blending of Mac OS X and iOS features. However,
# it's a nightmare to deal with in Sublime Text if you're running Vintage (Vim) mode,
# as it means you cannot press and hold h/j/k/l to move through your file. You have
# to repeatedly press the keys to navigate.
scottwb /
Created Feb 6, 2012
Monkey patches for a couple Rails Mime::Type.parse bugs.

Rails Mime::Type.parse Patches

There are two Rails issues in it's handling of the HTTP Accept header which cause a number of spurious exception emails via Airbrake. I am encountering this on Rails 3.0.7. One of these is fixed in a later version of Rails, but for other reasons I can't upgrade right now. The other bug is still present in Rails 3.2 and in master at the time of this writing. This gist includes some monkey patches you can apply to fix these issues until such time that they are fixed in Rails properly.

Rails Issue #736

Issue #736 is that Rails does not correctly parse a q-value in an Accept header when there is only one content-type specified. For example:

Accept: text/html;q=0.9
You can’t perform that action at this time.