Skip to content

Instantly share code, notes, and snippets.

@lakemove
lakemove / weixin_crypt.go
Last active December 29, 2022 15:42
weixin api message encryption and decryption
package main
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/sha1"
"encoding/base64"
"encoding/binary"
@lakemove
lakemove / main.go
Created November 14, 2020 07:22
golang v4 UUID generator
package main
import (
"crypto/rand"
"encoding/hex"
"fmt"
)
func main() {
id := make([]byte, 16)
@lakemove
lakemove / gist:34602b4c7c64052ae563cb27f5dd5cfe
Last active September 9, 2019 16:35
search, select and execute from bash history
history | dmenu -l 10 | bash
@lakemove
lakemove / run-groovy.ipynb
Created January 13, 2018 04:07
run groovy in jupyter/ipython notebook, put it in one cell and ctrl+enter to run
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lakemove
lakemove / groovy-in-bash.sh
Created January 13, 2018 03:52
run groovy script in bash script
#!/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
@lakemove
lakemove / oneliner.groovy
Created June 20, 2017 15:54
one liner in 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
@lakemove
lakemove / coursera_download.sh
Created March 23, 2016 11:31
download all video lectures, of a single course
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
@lakemove
lakemove / DeadSimpleAuthFilter.java
Last active August 29, 2015 14:14
Form based authentication Filter, with in Servlet Container
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 / gist:5b804f0c9dda892d80d9
Created December 12, 2014 06:37
javamail read mail
@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");
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