This gist is no longer valid. Please see Compass-Rails for instructions on how to install.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -wKU | |
JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home" | |
JAVA="#{JAVA_HOME}/bin/java" | |
GIT_ROOT=ENV['GIT_ROOT'] | |
CLJ="/opt/clojure" | |
LIB="#{GIT_ROOT}/library" | |
classpath=".:src:test:classes" + | |
":#{GIT_ROOT}/formpluslogic/fpl-clojure-util/fpl-clojure-util.jar" + | |
":#{CLJ}/swank-clojure/src/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This is when a refactoring really pays off. | |
* | |
* In order to make your code more modular, avoid hard-coding assumptions (or refactor them away). | |
* The most fundamental, anti-modular assumption in Object-Oriented software is the concrete type of objects. | |
* Any time you write "new MyClass" in your code (or in Ruby MyClass.new) you've hardcoded | |
* an assumption about the concrete class of the object you're allocating. These makes it impossible, for example, | |
* for someone to later add logging around method invocations of that object, or timeouts, or whatever. | |
* | |
* In a very dynamic language like Ruby, open classes and method aliasing mitigate this problem, but | |
* they don't solve it. If you manipulate a class to add logging, all instances of that class will have |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Memcached cache backend" | |
from django.core.cache.backends import memcached | |
from django.utils.encoding import smart_unicode, smart_str | |
MIN_COMPRESS_LEN = 150000 | |
class CacheClass(memcached.CacheClass): | |
def add(self, key, value, timeout=None, min_compress_len=MIN_COMPRESS_LEN): | |
if isinstance(value, unicode): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# WPF Clock in IronRuby! | |
# <[email protected]> | |
require 'WindowsBase' | |
require 'PresentationFramework' | |
require 'PresentationCore' | |
require 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' | |
class Clock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NOTE: | |
# This version is out-of-date. | |
# Please access http://github.com/maraigue/devnull for the versions under development. | |
# Ruby implementation of null file (like /dev/null on Un*x, NUL on Windows) | |
# (C) 2010- H.Hiro(Maraigue) [email protected] | |
# | |
# DevNull works like an IO object. For example: | |
# dn = DevNull.new | |
# dn.puts "foo" # => nil (do nothing) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# | |
# Since unicorn creates a new pid on restart/reload, it needs a little extra love to | |
# manage with runit. Instead of managing unicorn directly, we simply trap signal calls | |
# to the service and redirect them to unicorn directly. | |
# | |
# To make this work properly with RVM, you should create a wrapper for the app's gemset unicorn. | |
# | |
function is_unicorn_alive { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AvatarUploader < CarrierWave::Uploader::Base | |
include CarrierWave::MiniMagick | |
def extension_white_list | |
model.skip_avatar_extension_check ? nil : %w(jpg jpeg gif png bmp) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
logger () | |
{ | |
time=`TZ="Asia/Shanghai" date +"%Y-%m-%d %T"`; | |
echo "[$time] $*" | |
} | |
rm () | |
{ | |
local limit=50; | |
if [ -d $HOME/.local/share/Trash/files ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
OlderNewer