Skip to content

Instantly share code, notes, and snippets.

@leVirve
leVirve / echo socket-server
Created April 10, 2015 15:21
Multithreading echo socket-server in Python3
import socketserver
from threading import Thread
class service(socketserver.BaseRequestHandler):
def handle(self):
while True:
self.data = self.request.recv(1024).strip()
if not self.data:
@leVirve
leVirve / echo socket-client
Created April 10, 2015 15:22
socket-client in Python3
import socket
import sys
HOST, PORT = "localhost", 5566
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
sock.connect((HOST, PORT))
for data in sys.stdin:
@leVirve
leVirve / nthu
Last active August 29, 2015 14:21
NTHU ID Rule
data = {
"0000": ["跨系學士班", "跨系學士班"],
"0008": ["跨系博士班", "跨系博士班"],
"0015": ["先進光源科技學位學程物理組碩士班", "先進光源科技學位學程"],
"0016": ["先進光源科技學位學程工科組碩士班", "先進光源科技學位學程"],
"0018": ["先進光源科技學位學程博士班", "先進光源科技學位學程"],
"0025": ["學習科學研究所碩士班", "學習科學研究所"],
"0100": ["原科院學士班", "原科院學士班"],
"0111": ["工程與系統科學系清班", "工程與系統科學系"],
"0112": ["工程與系統科學系華班", "工程與系統科學系"],
@leVirve
leVirve / youtube_playlists.py
Last active October 14, 2023 23:03
Retrieve the video metadata from your Youtube playlists!
import os
import sys
import httplib2
from apiclient.discovery import build
from oauth2client.client import flow_from_clientsecrets
from oauth2client.file import Storage
from oauth2client.tools import argparser, run_flow
# The CLIENT_SECRETS_FILE variable specifies the name of a file that contains
@leVirve
leVirve / linux_shell.md
Last active August 29, 2015 14:25
tutorial for group

ls

  • ls: 列出目前資料夾下檔案
  • ls -l: 列出目前資料夾下檔案(詳細資訊)
  • ls -a: 列出目前資料夾下所有檔案(包含隱藏檔, .開頭)
  • ls -al (參數可以組合)
  • ls --color (將結果上色顯示)

dir/file

  • mkdir: 新增資料夾
  • rmdir: 移除資料夾 (底下要是空的)
@leVirve
leVirve / en
Last active September 9, 2015 02:49
Keefox Translation
KeeFox-FAMS-NotifyBar-A-Donate-Button.key= D
KeeFox-FAMS-NotifyBar-A-Donate-Button.label= Donate now
KeeFox-FAMS-NotifyBar-A-LearnMore-Button.key= L
KeeFox-FAMS-NotifyBar-A-LearnMore-Button.label= Learn more
KeeFox-FAMS-NotifyBar-A-Rate-Button.key= R
KeeFox-FAMS-NotifyBar-A-Rate-Button.label= Rate KeeFox now
KeeFox-FAMS-NotifyBar-A-VisitSite-Button.key= G
KeeFox-FAMS-NotifyBar-A-VisitSite-Button.label= Go to site
KeeFox-FAMS-NotifyBar-DoNotShowAgain-Button.key= N
KeeFox-FAMS-NotifyBar-DoNotShowAgain-Button.label= Don't show message again
CFLAGS = -std=c11 -O3
CPPFLAGS = -O3
LOGFLAGS = -D_DEBUG -D_INFO -D_FILE_DEBUG
OUTPUT = debug_job.* judge_out_* *.o *.result
all: clean advanced submit
basic:
mpicc -o basic.o basic.c $(CFLAGS) $(LOGFLAGS)
@leVirve
leVirve / jobs_qsub.py
Last active December 14, 2015 04:49
PBS submit script
#! /usr/bin/python
"""
Run this script with below command! (y)
$> nohup ./src/jobs.py > jobs_py.stdout 2> jobs_py.stderr < /dev/null &
"""
import re
import time
import subprocess
job_format = """
@leVirve
leVirve / kmeans.m
Created February 22, 2016 09:28
K-Means on RGB image
optns = statset('MaxIter', iters);
pixels = reshape(img(:), [], 3);
[idxs, centroids] = kmeans(pixels, k, 'options', optns);
img_map = centroids(idxs, :);
img_new = reshape(img_map(:), size(img));
imshow(img_new);
@leVirve
leVirve / Note.md
Last active June 11, 2016 05:48
MIR Final Project