Skip to content

Instantly share code, notes, and snippets.

View y3nr1ng's full-sized avatar

Liu, Yen-Ting y3nr1ng

View GitHub Profile
@y3nr1ng
y3nr1ng / README
Last active August 29, 2015 14:25 — forked from rwest/README
Convert OS X Keychain exported entries into logins for 1Password import
These two files should help you to import passwords from mac OS X keychains to 1password.
Assumptions:
1) You have some experience with scripting/are a power-user. These scripts worked for me
but they haven't been extensively tested and if they don't work, you're on your own!
Please read this whole document before starting this process. If any of it seems
incomprehensible/frightening/over your head please do not use these scripts. You will
probably do something Very Bad and I wouldn't want that.
2) You have ruby 1.9.2 installed on your machine. This comes as standard with Lion, previous
versions of OS X may have earlier versions of ruby, which *may* work, but then again, they
@y3nr1ng
y3nr1ng / mover
Created April 5, 2016 08:14
Simple script to move all the files from subdirectory to root.
#!/usr/bin/env python
import shutil, os, sys
# current working directory
dest_dir = os.getcwd()
dir = []
for root, dirs, files in os.walk(dest_dir):
for name in files:
from multiprocessing import Pool, Manager
import yaml
import re
import math
from count import Count
from statistic import MI, LogLikelihood
import jieba
n_workers = 16
@y3nr1ng
y3nr1ng / d2v-class
Last active May 19, 2016 16:27
Task 2 - Doc2Vec
#!/usr/bin/env python3
import os, argparse, logging
# get cpu cores
import multiprocessing
# doc2vec
from gensim.models import Doc2Vec
from gensim.models.doc2vec import LabeledSentence
from gensim import utils
# array storage
@y3nr1ng
y3nr1ng / words-crawl.py
Created May 19, 2016 16:45
Dictionary Crawler
#!/usr/bin/env python3
import requests, json, sys, random
from html.parser import HTMLParser
from time import sleep
from tqdm import tqdm
import cProfile
url = 'http://words.sinica.edu.tw/ftms-bin/scripts/words_scripts/zizi1.pl'
from gensim.models.doc2vec import Doc2Vec
from gensim.test.test_doc2vec import ConcatenatedDoc2Vec
from sklearn.linear_model import LogisticRegression, SGDClassifier, LogisticRegressionCV
from sklearn import svm
from sklearn.externals import joblib
import jieba
import numpy as np
import logging
import os
import sys
@y3nr1ng
y3nr1ng / cmb-test.py
Created May 19, 2016 17:49
Task 2 - Voting
#!/usr/bin/env python3
import os, sys, argparse, logging
baseline = '/tmp2/b03902036/train-punc.pro'
result = '/tmp2/b03902036/result.cmb'
ground_truth = dict()
with open(baseline, 'r') as in_file :
for line in in_file :
@y3nr1ng
y3nr1ng / genpkl
Created May 19, 2016 17:51
Task 2 - DNN
#!/usr/bin/env python3
import os, argparse, logging
# using doc2vec model
from gensim.models import Doc2Vec
# generate compressed pickle file
import pickle, numpy, gzip
logging.basicConfig(format='%(asctime)s [%(levelname)s] %(message)s')
@y3nr1ng
y3nr1ng / gifextract.py
Last active July 10, 2016 06:14 — forked from BigglesZX/gifextract.py
Extract frames from an animated GIF, correctly handling palettes and frame update modes
'''
A fork of this gist https://gist.github.com/BigglesZX/4016539 .
Ported to Python3 and verify it with Pillow.
'''
import argparse
import os
from PIL import Image
def find_dir(path):
@y3nr1ng
y3nr1ng / batchsips.sh
Last active September 18, 2016 01:02
Batch image format conversion using SIPS (Scriptable Image Processing System) in OS X.
#!/bin/bash
echo ""
read -e -p "Target folder name: " folder
echo "Duplicate folder structure of $folder.."
if [ -d "Compressed-${folder}" ]; then
echo ""
read -r -p "\"Compressed-${folder}\" exist, overwrite? [y/n] " response
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]