Skip to content

Instantly share code, notes, and snippets.

Minwei Shen MinweiShen

Block or report user

Report or block MinweiShen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View days_of_month.js
return month === 1 ?
((year % 4 ===0 && year%100!==0) or year %400===0) ? 28 : 29) : /* February */
((month % 2) ^ (month < 7) ? 31 : 30); /* Other months */
View scrapy_save_chinese_pipeline.py
import json,codecs
class WebCrawlerScrapyPipeline(object):
def __init__(self):
self.file = codecs.open('item.json', 'wb', encoding='utf-8')
def process_item(self, item, spider):
line = json.dumps(dict(item)) + '\n'
# print line
View gist:ee7538dfff14d1359343
<?xml version="1.0"?>
<root>
<item>
<name>Remap KANA to F18</name>
<identifier>space_cadet.kana_to_f18</identifier>
<autogen>__KeyToKey__ KeyCode::JIS_KANA, KeyCode::F18</autogen>
</item>
View gist:939396ef075bdadd156d
# 定义查找窗口切换时显示在每个窗口图标的字符,类似于Vim的easymotion插件
alias showHintsLeftHand hint ASDFQWERT
alias showNormalHint hint QWERTASDFGZXCVYUIOPHJKLBNM
#KANA is remap to F18
#EISUU is remap to F19
# 一些位置定义:全屏,左半屏,右半屏等等
@MinweiShen
MinweiShen / Misra_Gries.py
Created Mar 24, 2015
Misra_Gries algorithm
View Misra_Gries.py
def Misra_Gries(file,k):
result = {}
to_delete = []
with open(file,"r") as f:
for l in f.readlines():
chars = l.split()
for ch in chars:
to_delete = []
if ch in result:
result[ch] = result[ch] + 1
@MinweiShen
MinweiShen / sublime_setting
Last active Aug 29, 2015
Sublime Text 3 User setting
View sublime_setting
{
"color_scheme": "Packages/Color Scheme - Default/Espresso Libre.tmTheme",
"font_size": 13,
"ignored_packages":
[
"Vintage"
],
// show spaces
"draw_white_space": "all",
// the theme
@MinweiShen
MinweiShen / syscall_example
Created Jan 22, 2015
a simple example of using syscall()
View syscall_example
#include <stdio.h>
#include <fcntl.h>
/*arguments of syscall can be found on http://blog.rchapman.org/post/36801038863/linux-system-call-table-for-x86-64*/
int main(int argc, char* argv[]){
const char* fileName[7] = "me.txt";
//create a file that the owner can read/write. flags can be found easily by google
syscall(SYS_open,fileName,O_CREAT,S_IRUSR|S_IWUSR);
//open it as write only
int fd = syscall(SYS_open,fileName,O_WRONLY);
You can’t perform that action at this time.