Skip to content

Instantly share code, notes, and snippets.

View reyesyang's full-sized avatar

Yang Hailong reyesyang

View GitHub Profile
#!/bin/bash
#
# Download and install libevent and memcached from source on Debian Etch or
# Debian Lenny.
#
# Assumptions
# - libevent and memcached have not been installed from apt repositories
# - memcached is not already running
# - it is ok to clobber scripts at
# /etc/memcached.conf
@reyesyang
reyesyang / Translation.rb
Created April 11, 2013 09:27
Rewrite human_attribute_name method in ActiveModel::Translation file for Padrino project which use ActiveRecord as ORM.
module ActiveModel
module Translation
include ActiveModel::Naming
def human_attribute_name(attribute, options = {})
options = { :count => 1 }.merge!(options)
parts = attribute.to_s.split(".")
attribute = parts.pop
namespace = parts.join("/") unless parts.empty?
attributes_scope = "models"
@reyesyang
reyesyang / AjaxExceptionHandler.js
Created April 11, 2013 09:54
Ajax exception handler for rails-ujs
on('ajax:error', function(e, xhr, status, errors){
var error;
try {
error = $.parseJSON(xhr.responseText);
} catch(e) {
error = {message: '服务器忙,请稍后再试!'};
}
//code to show error message
@reyesyang
reyesyang / getSelectionText.js
Created April 23, 2013 15:26
Method to get selection text.
function getSelectionText() {
var text = "";
if (window.getSelection) {
text = window.getSelection().toString();
} else if (document.selection && document.selection.type != "Control") {
text = document.selection.createRange().text;
}
return text;
}
@reyesyang
reyesyang / font.css
Created April 24, 2013 15:32
Font CSS basic settings
body {
font-family: "Helvetica Neue",​Helvetica,​Arial,​sans-serif
font-size: 14px;
color: #333333;
line-height: 20px;
}
function GetWidth()
{
var x = 0;
if (self.innerHeight)
{
x = self.innerWidth;
}
else if (document.documentElement && document.documentElement.clientHeight)
{
x = document.documentElement.clientWidth;
class Object
def eigenclass
class << self; self; end
end
end
@reyesyang
reyesyang / link_text_overflow.css
Created June 28, 2013 06:24
Hidden overflow text in link element
/* Solarized Dark
For use with Jekyll and Pygments
http://ethanschoonover.com/solarized
SOLARIZED HEX ROLE
--------- -------- ------------------------------------------
base03 #002b36 background
base01 #586e75 comments / secondary content
@reyesyang
reyesyang / clear_after.css
Created December 20, 2013 07:18
Clear float with :after
&:after {
content: ".";
display:block;
height:0;
clear:both;
visibility:hidden;
}