Skip to content

Instantly share code, notes, and snippets.

View zarzen's full-sized avatar

Zhen Zhang zarzen

View GitHub Profile

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 / 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 / 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 / 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 / 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 / android-perm-desc.json
Last active April 15, 2018 18:43
facebook platform permissions
{
"find accounts on the device": "Allows the app to get the list of accounts known by the device. This may include any accounts created by applications you have installed.",
"read your text messages (sms or mms)": "Allows the app to read SMS messages stored on your device or SIM card. This allows the app to read all SMS messages, regardless of content or confidentiality.",
"receive text messages (sms)": "Allows the app to receive and process SMS messages. This means the app could monitor or delete messages sent to your device without showing them to you.",
"send sms messages": "Allows the app to send SMS messages. This may result in unexpected charges. Malicious apps may cost you money by sending messages without your confirmation.",
"edit your text messages (sms or mms)": "Allows the app to write to SMS messages stored on your device or SIM card. Malicious apps may delete your messages.",
"read the contents of your usb storage": "Allows the app to read the contents of your USB storage.",
"modif
@zarzen
zarzen / spacemacs-org-pomodoro.org
Last active July 20, 2018 20:39
spacemacs org-pomodoro setup for Windows

Install mplayer

Download from sourceforge

Set Audio Player in .spacemacs

(setq org-pomodoro-audio-player "C:/Applications/mplayer/mplayer.exe ")

Write this code under dotspacemacs/user-config

Why not use VLC

vlc.exe only work with backslash in windows system, but org-pomodoro use slash as path separator.

@zarzen
zarzen / unicodeToAscii.py
Last active August 13, 2018 20:24
turn unicode string to plain ascii
# Turn a Unicode string to plain ASCII, thanks to
# http://stackoverflow.com/a/518232/2809427
def unicodeToAscii(s):
return ''.join(
c for c in unicodedata.normalize('NFD', s)
if unicodedata.category(c) != 'Mn'
)
@zarzen
zarzen / sent_split.py
Last active October 27, 2018 03:15
sentence splitting
import json
import spacy
import string
import re
from nltk.tokenize.stanford_segmenter import StanfordSegmenter
from nltk.tokenize import sent_tokenize
def remove_nonascii(document):
printable = set(string.printable)
class Solution:
"""
@param board: the sudoku puzzle
@return: nothing
"""
def solveSudoku(self, board):
# write your code here
# if not board: return
# print('start')
empty_cells = self.getEmptyXY(board)