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
@michaelkoper
michaelkoper / apache_bench.sh
Last active Jun 2, 2016 — forked from seyhunak/apache_bench.sh
Rails - Apache Bench - Load Testing (if Warden Sign-in Required)
View apache_bench.sh
1.
LOGIN_PAGE=http://localhost.dev/users/sign_in
curl --cookie-jar cookie_file $LOGIN_PAGE | grep csrf-token
2.
<meta content="csrf-token" name="csrf-token" />
View gist:debc900aa0c6779e896b
class CarrierStringIO < StringIO
def original_filename
# the real name does not matter
"photo.jpeg"
end
def content_type
"image/jpeg"
end
end
@michaelkoper
michaelkoper / backbone_pushstate_router.js
Last active Oct 5, 2016 — 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
michaelkoper / gist:6668097
Last active Dec 23, 2015
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
michaelkoper / gist:6668089
Last active Dec 23, 2015
Sublime User Preferences
View gist:6668089
{
"auto_complete": false,
"auto_match_enabled": false,
"bold_folder_labels": true,
"color_scheme": "Packages/User/railscasts.tmTheme",
"folder_exclude_patterns":[
".svn",
".git",
".hg",
"CVS",
@michaelkoper
michaelkoper / gist:5007636
Last active Jan 25, 2018
Handling with money in Mongoid
View gist:5007636
class Product
include Mongoid::Document
field :price, type: Money
end
Money.class_eval do
# Converts an object of this instance into a database friendly value.
def mongoize
@michaelkoper
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)
@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)
@michaelkoper
michaelkoper / gist:1605401
Created Jan 13, 2012
No asset debug messages
View gist:1605401
# put in config/initializers/filename.rb
Rails.application.assets.logger = Logger.new('/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
end
@michaelkoper
michaelkoper / extra_memcached_features.rb
Created Aug 4, 2011
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'
end
# Original method from the memcached store.
# Only difference is that we modify the key so we support Arrays
You can’t perform that action at this time.