Skip to content

Instantly share code, notes, and snippets.

View vigack's full-sized avatar

vigack

  • Hangzhou. China
View GitHub Profile
@vigack
vigack / arp.py
Created September 27, 2018 05:45
arp all local network using scapy
arping("192.168.1.*")
@vigack
vigack / build.gradle
Last active September 27, 2018 05:47
自动化合并前端代码草稿
buildscript {
ext {
springBootVersion = '1.5.6.RELEASE'
}
repositories {
jcenter()
}
dependencies {
classpath "org.projectlombok:lombok:1.16.18"
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
@vigack
vigack / 3sum.py
Last active May 11, 2018 07:50
3sum
class Solution:
def threeSum(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
nums.sort
solutions = []
d = {}
inx = 0
@vigack
vigack / lr0.py
Last active March 13, 2018 10:11
lr(0) algo implements by python. Based on <Modern Compiler Implemention in C> in ch03
cfg = []
ht = {}
class Token:
def __init__(self, val, is_term):
self.val = val
self.is_term = is_term
def __eq__(self, other):
return (self.val, self.is_term) == (other.val, other.is_term)
@vigack
vigack / level_order.py
Created February 20, 2018 15:20
Level order tree node traversal
def travel(root):
levels, level = [], [root]
while root and level:
levels.append([n.val for n in level])
level = [k for n in level for k in (n.left, n.right) if k]
return levels
@vigack
vigack / Psychic.java
Created January 12, 2018 08:54
Fuck java random
public class Psychic {
private static FuckRandom fuckRandom = new FuckRandom();
static {
fuckRandom.reverse(Math.random());
}
public static double guess(){
return fuckRandom.nextDouble();
@vigack
vigack / close_all.sh
Created January 3, 2018 05:00
一行代码关闭所有运行中的docker容器
docker ps|awk '{if (NR!=1) print $1}'| xargs docker stop
@vigack
vigack / graph.rb
Created December 18, 2017 06:14
Graph utils. Implements common graph api by ruby
class Graph
@adjlst
@v
@e
def initialize(size)
@adjlst = Array.new(size+1) { [] }
@v = size
end
@vigack
vigack / isMonostoneIncr.py
Created November 30, 2017 08:04
判断list是否单调递增
def isMonostoneInc(list):
return all(list[i], list[i+1] for i in range(len(list)-1))
@vigack
vigack / height.py
Last active November 30, 2017 07:08
find height of a binary tree without recursion
"""
基本思想:利用层序遍历,浮标法记录最大值
Node struct:
class Node:
def __init__(self, data, left, right):
self.data = data
self.left = left
self.right = right
"""