Skip to content

Instantly share code, notes, and snippets.

View michaelkoper's full-sized avatar

Michael Koper michaelkoper

  • Nusii
  • Madrid
View GitHub Profile
@kconragan
kconragan / keyrepeat.shell
Last active December 4, 2023 03:40
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.
@seyhunak
seyhunak / apache_bench.sh
Last active July 5, 2023 17:02
Rails - Apache Bench - Load Testing (if Devise Sign-in Required)
1.
LOGIN_PAGE=http://localhost/users/sign_in
curl --cookie-jar cookie_file $LOGIN_PAGE | grep csrf-token
2.
<meta content="csrf-token" name="csrf-token" />
@ssimeonov
ssimeonov / array_validator.rb
Last active March 22, 2022 14:48
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).
# Syntax sugar
class ArrayValidator < EnumValidator
end
@minuz
minuz / sassconvert.cmd
Created December 10, 2019 00:39
How to convert sass to scss
sass-convert -R ./ -F sass -T scss && find . -type f -name '*.sass' -delete
@bogdanconstantinescu
bogdanconstantinescu / application.rb
Created May 9, 2012 15:26 — forked from t2/application.rb
Formatting Rails form elements for Twitter Bootstrap error validation
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
html = %(<div class="field_with_errors">#{html_tag}</div>).html_safe
# add nokogiri gem to Gemfile
form_fields = [
'textarea',
'input',
'select'
]
@michaelkoper
michaelkoper / gist:4772413
Last active December 12, 2015 12:29
Some handy media queries for mobile devices
@mixin mobile
@media (min-device-width: 320px) and (max-device-width: 568px)
@content
@mixin mobile-portrait
@media (min-device-width: 320px) and (max-device-width: 568px) and (orientation:portrait)
@content
@mixin mobile-landscape
@media (min-device-width: 320px) and (max-device-width: 568px) and (orientation:landscape)
@beakr
beakr / gist:2688904
Created May 13, 2012 15:21
Custom fonts in Rubymotion
# Rakefile
Motion::Project::App.setup do |app|
# Use `rake config' to see complete project settings.
app.name = 'helloapp'
app.fonts = ['consolas.ttf']
end
# Put consolas.ttf in resources/
@scottwb
scottwb / README.md
Created February 6, 2012 20:45
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