Skip to content

Instantly share code, notes, and snippets.

Jay lakemove

Block or report user

Report or block lakemove

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lakemove
lakemove / coursera-download.sh
Last active Aug 29, 2015
download coursera lecture videos
View coursera-download.sh
#!/bin/bash
# download video by providing video url and cookie.
# saved file name will be from Content-Disposition
function download() {
local url=$1
local cookies=$2
local filename=$(curl -I -L -s --cookie "$cookies" "$url" | grep Content-Disposition | python -c "import sys, urllib as ul; print ul.unquote(sys.stdin.read());" | awk -F\" '{print $2}')
echo "start to download $filename"
@lakemove
lakemove / gist:9929800
Last active Aug 29, 2015
calculate mean and variance in a single iteration
View gist:9929800
// http://en.wikipedia.org/wiki/Variance
// http://upload.wikimedia.org/math/a/3/3/a336557f138eb90bafc9e6ebc00e926d.png
var data = [{x: 1, p: 0.1}, {x: 2, p: 0.3}, {x: 8, p: 0.6}]; //{x:probability}
var mu = 0, sigma = 0;
for (i in data) {
mu += i.p * i.x;
sigma += i.p * i.x * i.x;
View gist:503dd08604dca95681f7
deb http://ubuntu.v2ex.com/ubuntu/ quantal main restricted universe multiverse
deb-src http://ubuntu.v2ex.com/ubuntu/ quantal main restricted universe multiverse
deb http://ubuntu.v2ex.com/ubuntu/ quantal-updates main restricted universe multiverse
deb-src http://ubuntu.v2ex.com/ubuntu/ quantal-updates main restricted universe multiverse
deb http://ubuntu.v2ex.com/ubuntu/ quantal-backports main restricted universe multiverse
deb-src http://ubuntu.v2ex.com/ubuntu/ quantal-backports main restricted universe multiverse
deb http://ubuntu.v2ex.com/ubuntu/ quantal-security main restricted universe multiverse
deb-src http://ubuntu.v2ex.com/ubuntu/ quantal-security main restricted universe multiverse
deb http://extras.ubuntu.com/ubuntu quantal main
deb-src http://extras.ubuntu.com/ubuntu quantal main
View gist:5b804f0c9dda892d80d9
@Test
public String readMailTest() throws Exception {
Properties props = new Properties();
props.put("mail.imap.host", "imap.sina.cn");
Session session = Session.getDefaultInstance(props);
IMAPStore store = (IMAPStore) session.getStore("imap");
store.connect("sgmall_test_001", "sgmall_test_001");
Folder emailFolder = store.getFolder("INBOX");
@lakemove
lakemove / DeadSimpleAuthFilter.java
Last active Aug 29, 2015
Form based authentication Filter, with in Servlet Container
View DeadSimpleAuthFilter.java
package com.surdoc.enterprisecloud.web;
import java.io.IOException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
@lakemove
lakemove / commandline.bat
Created Jun 14, 2012
customized windows commandline
View commandline.bat
@ECHO OFF
doskey ls=dir /b $*
rem Java
set JAVA_HOME=C:\opt\jdk1.6.0_25
set Path=%JAVA_HOME%\bin;%Path%
rem Maven
set MVN_HOME=C:\opt\apache-maven-3.0.4
@lakemove
lakemove / commands.sh
Last active Oct 7, 2015
useful shell commands
View commands.sh
# tcpdump ldap traffic to a file, then can be analyzed by wireshark
sudo tcpdump -vv -w /tmp/ldapdump -i lo port 389
#sniff http traffic
sudo ngrep -q -d eth0 -W byline host example.com and port 8180
#Search recursively to find a word or phrase in certain file types, such as C code
find . -name "*.[ch]" -exec grep -i -H "search pharse" {} \; | column -t -s ":"
#search empty folder
@lakemove
lakemove / hudson-run.sh
Created Aug 8, 2012
script to bootstrap hudson in tomcat
View hudson-run.sh
#/bin/bash
export JAVA_HOME=/usr/lib/jvm/jdk1.6.0_25
export CATALINA_HOME=/usr/lib/apache-tomcat-7.0.26
export CATALINA_BASE=/srv/hudson-ci
export HUDSON_HOME=/srv/hudson-ci/hudson-home
export PATH=$JAVA_HOME/bin:$PATH
# see http://stackoverflow.com/questions/76327/how-can-i-prevent-java-from-creating-hsperfdata-files
# to disable it , use "-XX:-UsePerfData" ,
@lakemove
lakemove / web
Created Oct 25, 2012
The essence of this technique
View web
//pure-CSS drop down menus
div.menu-bar ul ul {
display: none;
}
div.menu-bar li:hover > ul {
display: block;
}
//image pre-loader
function preloadImages() {
@lakemove
lakemove / blog-app.conf
Created Oct 29, 2012
node upstart script
View blog-app.conf
description "blog-app server"
author "Jay"
start on startup
stop on shutdown
script
#Your scripts
cd /home/jay/works/blog-app
You can’t perform that action at this time.