Skip to content

Instantly share code, notes, and snippets.

@HungYuHei
HungYuHei / gist:1330863
Created November 1, 2011 15:43
OpenJDK与SunJDK互相切换
查看系统提供的JDK版本信息
$ /usr/sbin/alternatives --config java
配置SunJDK
# /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_27/bin/java 2
# /usr/sbin/alternatives --config java
@HungYuHei
HungYuHei / image-instead-of-text.css
Created November 4, 2011 05:07
image instead of text, replace image
.replace {
display:block;
height:0;
overflow:hidden;
font-size:0;
letter-spacing:-1em;
text-indent:-1000em;
}
.heading {
width:135px;
@HungYuHei
HungYuHei / generate-random-password.rb
Created November 4, 2011 06:14
生成随机密码
def generate_password(length=6)
chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ23456789'
password = ''
length.times { |i| password << chars[rand(chars.length)] }
password
end
@HungYuHei
HungYuHei / gist:1369401
Created November 16, 2011 06:13
global gemset
gem install bundler --pre
gem install mongoid bson_ext haml heroku rb-inotify libnotify guard-livereload mini_magick carrierwave carrierwave-mongoid client_side_validations
@HungYuHei
HungYuHei / uninstall-all-gems.sh
Created November 16, 2011 06:51
uninstall all gems
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
@HungYuHei
HungYuHei / gist:1375621
Created November 18, 2011 04:38
kaminari-variables
@foo.current_page
@foo.num_pages
@foo.limit_value
@foo.total_count
@foo.last_page?
@foo.first_page?
@foo.num_pages
@HungYuHei
HungYuHei / namespaces.js
Created November 18, 2011 13:29
extend namespaces javascript
// top-level namespace being assigned an object literal
var myApp = myApp || {};
// a convenience function for parsing string namespaces and
// automatically generating nested namespaces
function extend( ns, ns_string ) {
var parts = ns_string.split('.'),
parent = ns,
pl, i;
if (parts[0] == "myApp") {
parts = parts.slice(1);
@HungYuHei
HungYuHei / gist:1382528
Created November 21, 2011 12:41
ssh key authorized_keys
cat ~/.ssh/id_dsa.pub | ssh me@remotebox "cat >> ~/.ssh/authorized_keys"
@HungYuHei
HungYuHei / gist:1408541
Created November 30, 2011 09:55
mac resources picture
/System/Library/CoreServices/Dock.app/Contents/Resources
@HungYuHei
HungYuHei / server.conf
Created December 18, 2011 06:01
openvpn server.conf
# place it in /etc/openvpn/server.conf
port 53
proto udp
dev tun
ca /etc/openvpn/ca.crt
cert /etc/openvpn/server.crt
key /etc/openvpn/server.key
dh /etc/openvpn/dh1024.pem