-
設定swap(預設為60, 當系統使用到超過40% memory, 就會嘗試使用swap)
sysctl -w vm.swappiness=0 # from 60 -> 0
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 socket | |
from pyos import Scheduler | |
from pyos import NewTask | |
from pyos import Accept, Send, Receive | |
def handle_client(client, addr): | |
print "Connection from", addr | |
while True: | |
data = yield Receive(client, 65536) |
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
# http://blog.hakril.net/articles/0-understanding-python-by-breaking-it.html | |
def get_ref(obj): | |
""" returns a c_size_t, which is the refcount of obj """ | |
return ctypes.c_size_t.from_address(id(obj)) |
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
/var/log/mongodb/mongod.log { | |
hourly | |
missingok | |
rotate 5 | |
compress | |
delaycompress | |
notifempty | |
create 0640 mongodb mongodb | |
sharedscripts | |
postrotate |
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
on cuckoo() | |
set dateStr to time string of (current date) | |
set meow to POSIX path of (path to resource "meow.mp3") | |
display notification dateStr with title "Meow" | |
do shell script ("afplay " & meow) | |
end cuckoo | |
script main | |
cuckoo() | |
end script |
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 math | |
from collections import Counter | |
def tf(word, doc): | |
word_counter = Counter(doc.split()) | |
return word_counter(word) / sum(word_counter.values()) | |
def idf(word, corpus): | |
return math.log(len(corpus) / (1 + sum(1 for doc in corpus if word in doc))) | |
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 <unistd.h> | |
#include <stdio.h> | |
#include <setjmp.h> | |
#include <signal.h> | |
jmp_buf j; | |
void try() | |
{ | |
printf("call try\n"); |
1) Filter Table
Filter is default table for iptables. So, if you don’t define you own table, you’ll be using filter table. Iptables’s filter table has the following built-in chains.
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 csv | |
import os | |
import plistlib | |
def parse_safari_reading_list_plist(): | |
plist = plistlib.load( | |
open(os.path.expanduser('~/Library/Safari/Bookmarks.plist'), 'rb')) | |
items = [] |
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
__kubectl_init_completion() | |
{ | |
COMPREPLY=() | |
_get_comp_words_by_ref "$@" cur prev words cword | |
} | |
__kubectl_get_pod() | |
{ | |
if declare -F _init_completion >/dev/null 2>&1; then | |
_init_completion -s || return |