Skip to content

Instantly share code, notes, and snippets.

View reyesyang's full-sized avatar

Yang Hailong reyesyang

View GitHub Profile
/* Solarized Dark
For use with Jekyll and Pygments
http://ethanschoonover.com/solarized
SOLARIZED HEX ROLE
--------- -------- ------------------------------------------
base03 #002b36 background
base01 #586e75 comments / secondary content
class Object
def eigenclass
class << self; self; end
end
end
function GetWidth()
{
var x = 0;
if (self.innerHeight)
{
x = self.innerWidth;
}
else if (document.documentElement && document.documentElement.clientHeight)
{
x = document.documentElement.clientWidth;
@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;
}
@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 / 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 / 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"
#!/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 / nancy.rb
Created December 1, 2015 10:06
Nancy is a Sinatra like micro framework for study base on thoughtbot blog: https://robots.thoughtbot.com/lets-build-a-sinatra
require 'rubygems'
require 'bundler/setup'
require 'rack'
require 'pry'
module Nancy
METHODS = %w(get post put patch delete head)
class Base
# https://robots.thoughtbot.com/writing-a-domain-specific-language-in-ruby
module Smokestack
@registry = {}
def self.registry
@registry
end
def self.define(&block)