Skip to content

Instantly share code, notes, and snippets.

View michaelkoper's full-sized avatar

Michael Koper michaelkoper

  • Nusii
  • Madrid
View GitHub Profile
michaelkoper /
Last active June 2, 2016 08:50 — forked from seyhunak/
Rails - Apache Bench - Load Testing (if Warden Sign-in Required)
curl --cookie-jar cookie_file $LOGIN_PAGE | grep csrf-token
<meta content="csrf-token" name="csrf-token" />
View gist:debc900aa0c6779e896b
class CarrierStringIO < StringIO
def original_filename
# the real name does not matter
def content_type
michaelkoper / backbone_pushstate_router.js
Last active October 5, 2016 21:28 — forked from tbranyen/backbone_pushstate_router.js
hijack links for pushState in Backbone. With open in new tab functionality.
View backbone_pushstate_router.js
// Use absolute URLs to navigate to anything not in your Router.
var openLinkInTab = false;
// Only need this for pushState enabled browsers
if (Backbone.history && Backbone.history._hasPushState) {
$(document).keydown(function(event) {
if (event.ctrlKey || event.keyCode === 91) {
openLinkInTab = true;
michaelkoper / gist:6668097
Last active December 23, 2015 17:19
Sublime User Keymap
View gist:6668097
{ "keys": ["ctrl+alt+super+d"], "command": "toggle_side_bar" },
{ "keys": ["super+shift+l"], "command": "expand_selection", "args": {"to": "line"} },
{ "keys": ["ctrl+super+r"], "command": "reveal_in_side_bar" },
{ "keys": ["super+shift+1"], "command": "focus_group", "args": { "group": 0 } },
{ "keys": ["super+shift+2"], "command": "focus_group", "args": { "group": 1 } },
{ "keys": ["alt+shift+up"], "command": "select_lines", "args": {"forward": false} },
{ "keys": ["alt+shift+down"], "command": "select_lines", "args": {"forward": true} },
{ "keys": ["command+shift+."], "command": "insert_snippet", "args": {"name": "Packages/User/erb.sublime-snippet"} },
{ "keys": ["ctrl+command+w"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete Line.sublime-macro"} },
michaelkoper / gist:6668089
Last active December 23, 2015 17:19
Sublime User Preferences
View gist:6668089
"auto_complete": false,
"auto_match_enabled": false,
"bold_folder_labels": true,
"color_scheme": "Packages/User/railscasts.tmTheme",
michaelkoper / gist:5007636
Last active January 25, 2018 18:25
Handling with money in Mongoid
View gist:5007636
class Product
include Mongoid::Document
field :price, type: Money
Money.class_eval do
# Converts an object of this instance into a database friendly value.
def mongoize
michaelkoper / gist:4772413
Last active December 12, 2015 12:29
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)
michaelkoper / gist:1605401
Created January 13, 2012 10:12
No asset debug messages
View gist:1605401
# put in config/initializers/filename.rb
Rails.application.assets.logger ='/dev/null')
Rails::Rack::Logger.class_eval do
def call_with_quiet_assets(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0
call_without_quiet_assets(env).tap do
Rails.logger.level = previous_level
michaelkoper / extra_memcached_features.rb
Created August 4, 2011 08:24
Extra features for memcache store Rails 2.1. Deleting a group of memcached keys.
View extra_memcached_features.rb
module ActiveSupport
module Cache
class MemCacheStore
module Common
KEY = 'all_keys'
# Original method from the memcached store.
# Only difference is that we modify the key so we support Arrays