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.
*/
@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>",
}
@anhang
anhang / localStorage.js
Created July 20, 2011 23:07
HTML5 Local Storage with Expiration
AZHU.storage = {
save : function(key, jsonData, expirationMin){
if (!Modernizr.localstorage){return false;}
var expirationMS = expirationMin * 60 * 1000;
var record = {value: JSON.stringify(jsonData), timestamp: new Date().getTime() + expirationMS}
localStorage.setItem(key, JSON.stringify(record));
return jsonData;
},
load : function(key){
if (!Modernizr.localstorage){return false;}
@calvincorreli
calvincorreli / mixins.css.scss
Created November 30, 2011 10:25
IE gradient mixin with SCSS/SASS
@mixin gradient($first, $second) {
background-color: $second;
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr='#{ie-hex-str($first)}', endColorstr='#{ie-hex-str($second)}');";
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr='#{ie-hex-str($first)}', endColorstr='#{ie-hex-str($second)}');;
zoom: 1;
background: -webkit-gradient(linear, left top, left bottom, from($first), to($second));
background: -moz-linear-gradient(top, $first, $second);
}
@saetia
saetia / gist:1623487
Last active May 1, 2024 19:55
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
@rija
rija / install_puppet_mac.sh
Created February 23, 2012 23:04
Installing Puppet on Mac OS X
#!/usr/bin/env bash
set -o errtrace
set -o errexit
facter_version=$1
puppet_version=$2
target_volume=$3
@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('/')
@devinrhode2
devinrhode2 / clean-scrollbar.css
Created May 2, 2012 03:42
Like, basically PERFECT scrollbars
/**
* Like, basically PERFECT scrollbars
*/
/*
It's pure CSS.
Since a quick google search will confirm people going crazy about Mac OS Lion scrollbars...
this has no fade-out effect.
In Mac OS Lion, the lowest common denominator is always showing scrollbars by a setting.
@brianmcallister
brianmcallister / maintain-ratio.scss
Last active December 9, 2022 20:18
Sass mixin for a responsive box that maintains an aspect ratio.
// Maintain ratio mixin. Great for responsive grids, or videos.
// https://gist.github.com/brianmcallister/2932463
//
// $ratio - Ratio the element needs to maintain.
//
// Examples
//
// // A 16:9 ratio would look like this:
// .element {
// @include maintain-ratio(16 9);
@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,