Skip to content

Instantly share code, notes, and snippets.

View kigawas's full-sized avatar
🎯
Focusing

Weiliang Li kigawas

🎯
Focusing
View GitHub Profile
@kigawas
kigawas / osc_8_24.c
Last active August 29, 2015 14:01
operating system concepts problem 8.24
#include "stdlib.h"
#include "stdio.h"
typedef unsigned long long int ll;
int main( int argc, char * argv[] ) {
ll v_addr = atoll( argv[1] );
ll page = v_addr;
ll offset = v_addr;
printf( "The address %llu contains:\n", v_addr );
@kigawas
kigawas / flight_query.php
Last active August 29, 2015 14:01
sql worthy of 70% score
<?php
include "config.php";
$dep_keyword = $_GET['dep_keyword'];
$des_keyword = $_GET['des_keyword'];
$tran_keyword = $_GET['tran_keyword'];
$count = 0;
$order_cate = 'price';
if( $dep_keyword == $des_keyword ){
$dep_keyword = "";
@kigawas
kigawas / karger.py
Last active August 29, 2015 14:02
Karger algorithm using python
from random import choice
from collections import Counter
from copy import deepcopy
g = {}
def kargerMinCut(g):
while len(g) > 2:
#Selecting a random vertex
u = choice(g.keys())
@kigawas
kigawas / clustering.cpp
Last active August 29, 2015 14:04
Algorithms: Design and Analysis, Part 2: Week 2, Problem 1
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
const int MAX_V = 100000;
const int MAX_E = 1000000;
typedef long long ll;
@kigawas
kigawas / ycomb.py
Last active April 9, 2016 03:39
y-combinator python
from __future__ import print_function
#Y-combinator
Y = lambda f: (lambda x: x(x))(lambda x: f(lambda *args: x(x)(*args)))
#fact
print(Y(lambda f: lambda n: 1 if n == 1 else n * f(n - 1))(5)) #120
#sum
print(Y(lambda f: lambda n: 1 if n == 1 else n + f(n - 1))(100)) #5050
@kigawas
kigawas / fix_docker_redis.sh
Last active June 19, 2018 03:57
Run redis in docker without warnings
sysctl vm.overcommit_memory=1
echo never > /sys/kernel/mm/transparent_hugepage/enabled
@kigawas
kigawas / initialize.sh
Last active June 19, 2018 04:10
Initialize docker on Ubuntu
apt-get update
apt-get install apt-transport-https ca-certificates curl software-properties-common -y -q
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
apt-get install docker-ce -y -q
@kigawas
kigawas / setup_ss.md
Created June 22, 2018 05:59
搭建Shadowsocks服务

系统版本

Ubuntu 18.04 LTS

防火墙规则

打开80 443和4000端口

@kigawas
kigawas / a.pyx
Created June 26, 2018 07:32
Cython example of multiple pyx files
cdef int _fib(int n):
cdef int i
cdef int a=0, b=1
for i in range(n):
a, b = a + b,a
return a
def fib(n):
return _fib(n)
^dmd\-fifajs\-h5\-ikuweb\.youku\.com:443
^dmd\-fifa\-h5\-ikuweb\.youku\.com:443
^http:\/\/acs\.youku\.com\/.*$
^acs\.youku\.com:443
^http:\/\/pl\-ali\.youku\.com\/.*$
^http:\/\/list\.youku\.com\/.*$
^http:\/\/api\.youku\.com\/.*$
^http:\/\/play\.youku\.com\/.*$
^http:\/\/play\-dxk\.youku\.com\/.*$
^http:\/\/play\-ali\.youku\.com\/.*$