This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"color_scheme": "Packages/Color Scheme - Default/Espresso Libre.tmTheme", | |
"font_size": 13, | |
"ignored_packages": | |
[ | |
"Vintage" | |
], | |
// show spaces | |
"draw_white_space": "all", | |
// the theme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 定义查找窗口切换时显示在每个窗口图标的字符,类似于Vim的easymotion插件 | |
alias showHintsLeftHand hint ASDFQWERT | |
alias showNormalHint hint QWERTASDFGZXCVYUIOPHJKLBNM | |
#KANA is remap to F18 | |
#EISUU is remap to F19 | |
# 一些位置定义:全屏,左半屏,右半屏等等 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return month === 1 ? | |
((year % 4 ===0 && year%100!==0) or year %400===0) ? 28 : 29) : /* February */ | |
((month % 2) ^ (month < 7) ? 31 : 30); /* Other months */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const get = require('lodash/get'); | |
function transform(source, schema, ...ext) { | |
const result = Object.create(null); | |
for (let prop of Object.getOwnPropertyNames(schema)) { | |
if (typeof schema[prop] === 'function') { | |
result[prop] = schema[prop](source[prop], source); | |
} else { | |
result[prop] = schema[prop]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cache(): | |
def __init__(self): | |
self._cache = { | |
'_index': {} | |
} | |
def set(self, key, value): | |
self._cache[key] = value | |
self.index(key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function asyncPool(poolSize, inputArray, fn) { | |
const all = []; | |
const inProgress = []; | |
for (const data of inputArray) { | |
const p = new Promise(resolve => resolve(fn(data))); | |
all.push(p); | |
if (inputArray.length > poolSize) { | |
const e = p.then(() => inProgress.splice(inProgress.indexOf(p), 1)); | |
inProgress.push(e); | |
if (inProgress.length >= poolSize) { |