Skip to content

Instantly share code, notes, and snippets.

@fuyufjh
fuyufjh / hackathon.py
Last active December 21, 2015 12:43
Huawei Hackthon Nnajing 2015 Solution
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = 'Eric Fu'
cipher_file = open('cipher.txt', 'r')
dict_file = open('dictionary.tsv', 'r')
matrix = []
for line in dict_file.readlines():
@fuyufjh
fuyufjh / GifPlayer.cpp
Last active June 22, 2016 11:23
Decode GIF animaion into images with OpenCV and GIFLIB
#include <iostream>
#include <opencv2/opencv.hpp>
#include <gif_lib.h>
int main(int ac, char **av)
{
int err;
GifFileType *f = DGifOpenFileName("test.gif", &err);
assert(f != NULL);
int ret = DGifSlurp(f);
package demo.powermock;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import static org.junit.Assert.*;
@fuyufjh
fuyufjh / cheatsheet.go
Last active November 30, 2016 02:22
Golang Cheatsheet
// Basic function
package main
import "fmt"
func add(x, y int) int {
return x + y
}
package main
import (
"compress/gzip"
"context"
"fmt"
"io"
"os"
"os/signal"
"path/filepath"
@fuyufjh
fuyufjh / rpc.proto
Last active January 29, 2017 13:13
syntax = "proto3";
package protocol;
import "google/protobuf/empty.proto";
service SSMgrSlave {
rpc Allocate(AllocateRequest) returns (google.protobuf.Empty) {}
rpc Free(FreeRequest) returns (google.protobuf.Empty) {}
rpc GetStats(google.protobuf.Empty) returns (Statistics) {}
Regions for aws
* eu-west-2
* ap-south-1
* us-east-2
* ap-northeast-2
* us-west-2
* ap-southeast-2
* eu-central-1
* eu-west-1
* ca-central-1
@fuyufjh
fuyufjh / certbot_renew.sh
Created March 8, 2017 16:54
Certbot Renew
#!/usr/bin/env bash
printf "\nattempt to renew certificates at " >>/var/log/certbot_cron.log 2>&1
date >>/var/log/certbot_cron.log 2>&1
certbot renew --pre-hook "systemctl stop nginx" --post-hook "systemctl start nginx" --standalone-supported-challenges http-01 >>/var/log/certbot_cron.log 2>&1
printf "renew finished\n" >>/var/log/certbot_cron.log 2>&1
@fuyufjh
fuyufjh / SplitStringInCpp.cpp
Created April 4, 2017 13:30
split string in cpp
char *dup = strdup(str.c_str());
for (char *token = strtok(dup, " ,;"); token != NULL; token = strtok(NULL, " ,;")) {
// do something with token
}
free(dup);
@fuyufjh
fuyufjh / readme.md
Created February 19, 2017 06:12
树莓派+shadowsocks实现科学上网