View main.go
package main | |
import ( | |
"crypto/rand" | |
"encoding/hex" | |
"fmt" | |
) | |
func main() { | |
id := make([]byte, 16) |
View gist:34602b4c7c64052ae563cb27f5dd5cfe
history | dmenu -l 10 | bash |
View run-groovy.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View groovy-in-bash.sh
#!/bin/bash | |
GREETINGS='HELLO GROOVY AND BASH' | |
echo $GREETINGS | |
#to interpret bash variable , remove single quotes in 'EOF' | |
groovy -e "new GroovyShell().evaluate(System.in.text)" <<'EOF' | |
println("this is groovy print") | |
EOF |
View oneliner.groovy
//turn list into map | |
assert [1:2,3:4] == [[1,2],[3,4],[1,2]].collectEntries {it} //{[it[0],it[1]]} | |
//sublist from nth to end | |
assert [3,4,5,6] == [1,2,3,4,5,6][2..-1] | |
assert [3,4,5,6] == [1,2,3,4,5,6][2, 3..-1] | |
//string to number | |
assert 1.2 == "1.2" as double |
View coursera_download.sh
curl -s -b "$cookie" "https://class.coursera.org/bitcointech-001/lecture" | grep download.mp4\?lecture_id | awk -F\" '{print $4}' | xargs curl -s -b "$cookie" | awk -F\" '{print $2}' | while read -r line; do wget --content-disposition "$line" ;done | |
while read -r line; do wget --content-disposition "$line"; done |
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; |
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"); |
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: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; |
NewerOlder