Skip to content

Instantly share code, notes, and snippets.

View merqlove's full-sized avatar

Alexander Merkulov merqlove

View GitHub Profile
@zimbatm
zimbatm / gist:487157
Created July 23, 2010 07:57
Temporary disable $stdout
/* Temporary disable $stdout
============================
This method works for Ruby and new sub-processes.
I have seen other techniques on the net which re-assign $stdout with another IO,
but then the sub-processes will still use the old stdout.
*/
@jamiehodge
jamiehodge / mount.rb
Created April 10, 2012 14:31
sinatra/mount
module Sinatra
module Mount
def mount(app, route="/#{app.name.downcase}")
%w{get post put delete patch options}.each do |method|
self.send method.to_sym, "#{route}*" do
app.call(
env.merge!(
'SCRIPT_NAME' => route.split('/').last,
'PATH_INFO' => params.delete('splat').join('/')
@jamiehodge
jamiehodge / sinatra-mount.rb
Created June 20, 2012 11:34
sinatra/mount
require 'sinatra/base'
module Sinatra
module Mount
def mount(app, route="/#{app.name.downcase}")
before "#{route}*" do
halt app.call(
env.merge(
'SCRIPT_NAME' => route.split('/').last,
@slagdang
slagdang / enable_trim.sh
Last active December 10, 2015 19:58 — forked from woods/enable_trim.sh
This script will enable TRIM support for 3rd Party SSDs on Mountain Lion and later. It will enable TRIM for ALL 3rd Party SSDs, so if you have two SSDs in your system, best be sure both support TRIM before running this. It is unclear if this patch also enables TRIM for rotational media, I'd have to look at the Darwin source to find that out.
#!/bin/bash
#
# Enable TRIM support for 3rd Party SSDs. Works for Mountain Lion, should work on earlier OSes too.
# Tested on 10.8.2, 10.8.3, 10.8.5, 10.9.0-10.9.5, 10.10.0-10.10.1, 10.10.4
#
# Run this script at your own risk, whether on 10.10 or earlier.
#
# This script works on MacOS 10.10-10.10.1 (Yosemite) but it has significant system security repercussions.
# To use it you must disable kext signing on your machine. This makes it easier for
# malware to infect your machine by disabling the feature which would detect unsigned
@chriseppstein
chriseppstein / Sass.scss
Last active December 11, 2015 12:18 — forked from Snugug/Sass.scss
@function add-grid($grid-definition) {
$grid-split: split_string($grid-definition, 'at');
$number: to-number(nth($grid-split, 2));
@debug $number;
@debug type-of($number);
@return $number;
}
@ivanxuu
ivanxuu / puma.sh
Last active December 19, 2015 09:08 — forked from runlevel5/puma.sh
#! /bin/sh
### BEGIN INIT INFO
# Provides: pumacontrol
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Puma web server

ruby-1.9.3 cumulative performance patch for rbenv

(I guarantee nothing. No warranty I am not responsible blah blah blah. Seems to work great for me so far. Thanks to Tyler Bird and Slayer who I forked this from.)

From merqlove:

I just made little improvement to this fix:

Now you can select Ruby BUILD via same name variable. Otherwise build version will be used by default.

@pch
pch / watermark.rb
Created January 18, 2011 13:43
Paperclip Watermark processor
class User
has_attached_file :photo,
:processors => [:watermark],
:styles => {
:medium => {
:geometry => "300x300>",
:watermark_path => "#{Rails.root}/public/images/watermark.png"
},
:thumb => "100x100>",
}
@fabn
fabn / ajax_select.js.coffee
Created October 13, 2015 09:24
ActiveAdmin completion inputs for huge associations
# Vendored javascript files
#= require select2
# Configure defaults for all select2 inputs
$.fn.select2.defaults.set 'theme', 'classic'
$.fn.select2.defaults.set 'placeholder', 'Type to search'
# document ready function
jQuery ->
@nickpiesco
nickpiesco / README.md
Last active March 21, 2017 22:23
Making Sass Linear Gradient Mixins Behave in IE

I wrote this fairly straightforward cross-browser linear gradient mixin:

@mixin gradient($from-color, $to-color) {
	background-color: mix($from-color, $to-color); /* Fallback */
	background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from($from-color), to($to-color));
	background-image: -webkit-linear-gradient(top, $from-color, $to-color); 
	background-image:    -moz-linear-gradient(top, $from-color, $to-color);
	background-image:     -ms-linear-gradient(top, $from-color, $to-color);
	background-image: -o-linear-gradient(top, $from-color, $to-color);