Skip to content

Instantly share code, notes, and snippets.

@jihao
jihao / jQuery.ready.js
Created December 13, 2011 05:12
jQuery.ready.js
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("a").click(function(event){
alert("As you can see, the link no longer took you to jquery.com");
event.preventDefault();
});
});
</script>
@jihao
jihao / ruby.observer.rb
Created December 15, 2011 09:05
ruby.observer.rb
require "observer"
class Tick
include Observable
def tick
loop do
now = Time.now
changed
@jihao
jihao / ruby.string.rb
Created December 16, 2011 09:16
ruby string examples
irb(main):023:0> "".respond_to? "=~"
=> true
irb(main):024:0> "".respond_to? "match"
=> true
irb(main):030:0> Regexp.compile("").respond_to? "match"
=> true
irb(main):032:0> Regexp.compile("").respond_to? "=~"
=> true
@jihao
jihao / css button links
Created December 20, 2011 09:26
css buttons
@jihao
jihao / DateFormat in java
Created January 4, 2012 15:09 — forked from haizhe-cto/DateFormat in java
DateFormat in java
public static void main(String[] args) throws IOException, ParseException {
String strDate = "2011-01-12 07:50:00";
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = formatter.parse(strDate);
System.out.println("Date="+date);
}
@jihao
jihao / post soap with httpclient.java
Created February 7, 2012 06:38
post soap request using apache-common-httpclient
private void postSOAPXML(String soapBody)
{
try {
// Get target URL
HttpClient httpclient = new DefaultHttpClient();
StringEntity strEntity = new StringEntity(soapBody, "text/xml", "UTF-8");
HttpPost post = new HttpPost(CAI3G_URL);
post.setHeader("SOAPAction","CAI3G#Create");
post.setEntity(strEntity);
@jihao
jihao / douban.fm-favourite-hunter.js
Created March 9, 2012 15:41
获取douban.fm加红心的歌曲名+艺术家的一行jQuery脚本
//获取douban.fm加红心的歌曲名+艺术家的jQuery脚本
//http://douban.fm/mine?start=0&type=liked
$('p.song_title').map(function(){return ($(this).text()+"-"+$(this).next('p.performer').text())})
result:
["踮起脚尖爱-洪佩瑜", "Innocent-久石譲", "晴朗-许巍", "时光-许巍", "Papa Was a Rodeo-Sara Lov", "Someone Like You-Adele", "一个像夏天一个像秋天-范玮琪", "風になる-サントラ", "遇见-孙燕姿", "左边-杨丞琳", "亲爱的你怎么不在身边-江美琪", "As Long As You Love Me-BACKSTREET BOYS", "爱情转移-陈奕迅", "情非得已-庾澄庆", "你要的爱-戴佩妮"]
Note:
可以将下面这行加成浏览器标签栏的bookmartlet
@jihao
jihao / github.css
Created August 14, 2012 02:45 — forked from theconektd/github.css
Github Markdown CSS - for Markdown Editor Preview
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {
@jihao
jihao / tomcat.sh
Last active August 29, 2015 14:15 — forked from valotas/tomcat.sh
#!/bin/bash
#
# tomcat7 This shell script takes care of starting and stopping Tomcat
#
# chkconfig: - 80 20
#
### BEGIN INIT INFO
# Provides: tomcat7
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
@jihao
jihao / tomcat7
Last active August 29, 2015 14:15
not standard tomcat auto start
Init script contents:
#!/bin/bash
### BEGIN INIT INFO
# Provides: tomcat7
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6