This file contains hidden or 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
equire 'cgi' | |
def unicode_utf8(unicode_string) | |
unicode_string.gsub(/\\u\w{4}/) do |s| | |
str = s.sub(/\\u/, "").hex.to_s(2) | |
if str.length < 8 | |
CGI.unescape(str.to_i(2).to_s(16).insert(0, "%")) | |
else | |
arr = str.reverse.scan(/\w{0,6}/).reverse.select{|a| a != ""}.map{|b| b.reverse} | |
# ["100", "111000", "000000"] | |
hex = lambda do |s| |
This file contains hidden or 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 ComputerHelper | |
{ | |
public static string GetMac() | |
{ | |
string mac = string.Empty; | |
System.Management.ManagementClass mc = new System.Management.ManagementClass("Win32_NetworkAdapterConfiguration"); | |
System.Management.ManagementObjectCollection moc2 = mc.GetInstances(); | |
foreach (System.Management.ManagementObject mo in moc2) | |
{ |
This file contains hidden or 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/sh | |
### BEGIN INIT INFO | |
# curl https://gist.github.com/870478.txt > nginx | |
# mv nginx /etc/init.d | |
# chmod +x /etc/init.d/nginx | |
# update-rc.d -f nginx defaults | |
### END INIT INFO | |
PATH=/opt/nginx/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin |
This file contains hidden or 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 | |
# http://wiki.agideo.com/agideowiki/show/S3Rsync | |
# require http://s3.amazonaws.com/ServEdge_pub/s3sync/s3sync.tar.gz | |
# install curl http://gist.github.com/631872.txt > sync2s3.bash | |
export AWS_ACCESS_KEY_ID=YOUR_ID | |
export AWS_SECRET_ACCESS_KEY=YOUR_PWD | |
export AWS_CALLING_FORMAT=SUBDOMAIN |
This file contains hidden or 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
# How to install Ruby on Rails on Ubuntu 10.04 (Server) Lucid Lynx | |
# --- | |
# Disclaimer: This are my own install of ruby env / rails steps. They work in my setups. | |
# Tested on x32 & x64 fresh copies of Ubuntu 10.04 server. | |
# --- | |
# TODO: add rvm/rails3 version of this steps | |
# --- | |
# you definitely want git installed ;) | |
sudo apt-get install git-core | |
# install ruby env |
This file contains hidden or 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
# customer.rb | |
before_destroy :check_used | |
def allow_destroy? | |
@allow_destory ||= LoadingBill.exists?(:author_id => self.id) | |
end | |
protected | |
def check_used |
This file contains hidden or 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
# 不是我的,也不知道原作者 | |
require 'date' | |
class NongLi | |
@@lunarInfo = [0x04bd8, 0x04ae0, 0x0a570, | |
0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2, | |
0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, | |
0x0ada2, 0x095b0, 0x14977, 0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, | |
0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970, 0x06566, |
This file contains hidden or 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
# http://stackoverflow.com/questions/517219/ruby-see-if-a-port-is-open | |
require 'socket' | |
require 'timeout' | |
def is_port_open?(ip, port) | |
begin | |
Timeout::timeout(1) do | |
begin | |
s = TCPSocket.new(ip, port) | |
s.close |
This file contains hidden or 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
rainux@immortal ~/devel/twi_meido | |
% YUKI.N> ruby d.rb | |
user system total real | |
0.770000 0.020000 0.790000 ( 0.802016) | |
0.730000 0.000000 0.730000 ( 0.740943) | |
0.760000 0.020000 0.780000 ( 0.793928) | |
user system total real | |
1.160000 0.010000 1.170000 ( 1.182798) | |
1.230000 0.030000 1.260000 ( 1.268377) |
This file contains hidden or 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
autoconf | |
bison | |
build-essential | |
checkgmail | |
colordiff | |
colorgcc | |
colormake | |
curl | |
cvs | |
devtodo |