Skip to content

Instantly share code, notes, and snippets.

View zarzen's full-sized avatar

Zhen Zhang zarzen

View GitHub Profile
@zarzen
zarzen / apkpure_crawler.py
Created March 27, 2018 22:28
apkpure crawler
import sqlite3
from sqlite3 import Error
from tqdm import tqdm
import requests
import urllib.request
from pyquery import PyQuery as pq
from os.path import join
from requests import HTTPError
import time
@zarzen
zarzen / change_pixel.py
Created August 23, 2017 15:19
change_pixel
import scipy.misc
def change_pixel(img, new_name):
"""
Args: img, numpy array
Returns:
new_img
@zarzen
zarzen / AnnotatedReview.py
Last active April 11, 2017 05:27
Annotate Data
class AnnotatedReview:
def __init__(self, sentence, feature_list, opinion_list):
self.sentence = sentence
self.feature_list = feature_list
self.opinion_list = opinion_list
def __str__(self):
return self.sentence
def __repr__(self):
@zarzen
zarzen / sniffer.py
Last active November 28, 2017 19:45
sniff a specific interface
from scapy.all import *
import atexit
#
packet_stats = {}
def print_stats():
print("\npacket statistics")
print(packet_stats)
@zarzen
zarzen / send-packet.py
Last active November 12, 2021 04:01
using scapy create tcp packet and catch it by wireshark
from scapy.all import *
def main():
"""
"""
packet = IP(dst="192.168.100.123")/TCP()/"from scapy packet"
send(packet)
def packet_with_seq_n():
@zarzen
zarzen / ovs-example.md
Last active December 29, 2023 07:09
ovs example

install openvswitch 2.4

uninstall ovs-2.5

sudo apt autoremove  openvswitch-common openvswitch-switch-dpdk openvswitch-dbg openvswitch-pki openvswitch-ipsec openvswitch-switch openvswitch-switch-dpdk openvswitch-ipsec openvswitch-test openvswitch-testcontroller openvswitch-vtep

download source code

wget http://openvswitch.org/releases/openvswitch-2.4.0.tar.gz

unpack and compile

@zarzen
zarzen / install.md
Created December 21, 2016 21:22
YCMD installation

Install vim vundle

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

config vimrc

add following into ~/.vimrc

set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim

install hunspell

brew install hunspell find the dictionary

en dictionary

then move dictionary to ~/Library/Spelling, thus hunspell can find it. using hunspell -D list search directories.

@zarzen
zarzen / Q1-e-p2
Last active September 12, 2016 13:03
Outer join equivalent
SELECT
p1.cid, p2.cid, p1.n + p2.n
FROM
(SELECT
cid, COUNT(Temp.pid) AS n
FROM
(SELECT DISTINCT
cid, pid
FROM
Purchase) AS Temp
  • Get an error while testing
Traceback (most recent call last):
  File "example/image-classification/train_mnist.py", line 1, in <module>
    import find_mxnet
  File "/Users/zarzen/Development/mxnet/example/image-classification/find_mxnet.py", line 2, in <module>
    import mxnet as mx
  File "/usr/local/lib/python2.7/site-packages/mxnet-0.7.0-py2.7.egg/mxnet/__init__.py", line 7, in <module>
    from .base import MXNetError