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 / 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 / gist:34602b4c7c64052ae563cb27f5dd5cfe
Last active September 9, 2019 16:35
search, select and execute from bash history
history | dmenu -l 10 | bash
@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 / pom.xml
Created June 9, 2012 08:39
maven pom.xml basic structure
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.liulijie</groupId>
<artifactId>blog-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
@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 / ti-svn-structure.sh
Created March 28, 2013 06:34
showcase svn automated operations and invoking Java from shell script
#!/bin/bash
WORKDIR=/tmp/svn-work-dir
mkdir $WORKDIR && cd $WORKDIR
svn info svn+ssh://subversion.evenex.com/svn/comp/OutgoingDocumentReceiveService/branches/FDD-4256 >/dev/null
if [ $? -eq 0 ]; then
echo "branch already exist, delete it [y/n](y)?"
svn rm svn+ssh://subversion.evenex.com/svn/comp/OutgoingDocumentReceiveService/branches/FDD-4256 -m "delete to create"
fi
@lakemove
lakemove / jgit.sh
Created March 21, 2013 03:19
self-executable shell commandline shamelessly copied from [jgit|http://www.eclipse.org/jgit/download/]
cmd=
for a in "$@"
do
case "$a" in
-*) continue ;;
*) cmd=$a; break; ;;
esac
done
use_pager=