Skip to content

Instantly share code, notes, and snippets.

@fuyufjh
fuyufjh / cheatsheet.py
Last active February 19, 2024 00:36
My Python Cheatsheet
Python Cheatsheet
=================
################################ Input & Output ###############################
name = input('please enter your name: ')
print('hello,', name)
ageStr = input('please enter your age: ')
age = int(ageStr)
@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 / nju-lan-route.sh
Last active October 10, 2020 12:04
南京大学内网路由设置
route add -net 114.212.0.0/16 gw 172.26.0.1
route add -net 172.16.0.0/12 gw 172.26.0.1
route add -net 210.28.128.0/20 gw 172.26.0.1
route add -net 58.192.32.0/20 gw 172.26.0.1
route add -net 58.192.48.0/21 gw 172.26.0.1
route add -net 202.38.2.0/23 gw 172.26.0.1
route add -net 202.38.143.0/24 gw 172.26.0.1
route add -net 202.119.32.0/19 gw 172.26.0.1
route add -net 210.29.240.0/20 gw 172.26.0.1
route add -net 219.219.112.0/20 gw 172.26.0.1
@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);
@fuyufjh
fuyufjh / baguenaudier.cpp
Created July 23, 2016 18:19
Algorithm to solve Baguenaudier (aka. Chinese Rings)
#include <cstdio>
#include <algorithm>
const int MAX_N = 20;
int n;
bool state[MAX_N];
int count_op = 0;
void print_state()
{
Index: ppp-2.4.7/pppd/chap-md5.c
===================================================================
--- ppp-2.4.7.orig/pppd/chap-md5.c 2014-08-09 12:31:39.000000000 +0000
+++ ppp-2.4.7/pppd/chap-md5.c 2014-09-28 15:05:32.517737058 +0000
@@ -1,6 +1,12 @@
/*
* chap-md5.c - New CHAP/MD5 implementation.
*
+ * Modified for Damning China Telecom Campus Broadband Access.
+ *
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) {}