Skip to content

Instantly share code, notes, and snippets.

View Leechael's full-sized avatar
🐹
Working from home

Leechael Leechael

🐹
Working from home
View GitHub Profile
function F(){}
Object.defineProperty(F.prototype, 'foo', {
get: function(){ return F._foo; },
set: function(value){ F._foo = value; }
});
var obj = new F();
obj.foo; // undefined
obj.foo = 1;
function! Jump2PrevDiffText()
let line=line(".")
let idx=col(".")-1
if synIDattr(diff_hlID(line, idx), "name")=="DiffChange" || synIDattr(diff_hlID(line, idx), "name")=="DiffText"
while idx>0
if synIDattr(diff_hlID(line, idx), "name")=="DiffText" && synIDattr(diff_hlID(line, idx-1), "name")!="DiffText"
call setpos(".", [0,line,idx])
break
elseif idx==1
let line=line(".")
@cowboy
cowboy / javascript-type-stuff.js
Created February 16, 2011 16:13
JavaScript Type Stuff
// ============================================================
// Objects vs Primitives
// To make a long story short, use primitives wherever you can.
// ============================================================
// Primitive types: Null, Undefined, Number, Boolean, String.
var num1 = 9000,
num2 = new Number( 9000 ),
str1 = "hello world",
@abbas-obscurus
abbas-obscurus / pytc.c.patch
Created December 2, 2011 09:23
pytc rangefwm function now accept pefixes with embedded null bytes
--- pytc.c.orig 2011-12-01 02:31:54.000000000 +0400
+++ pytc.c 2011-12-01 02:32:21.000000000 +0400
@@ -1555,14 +1555,15 @@
int max;
TCLIST *list;
char *prefix;
+ int prefix_len;
static char *kwlist[] = {"prefix", "max", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "si:rangefwm", kwlist,
@frsyuki
frsyuki / fluentd-v11-design.md
Created May 8, 2012 19:31
Fluentd v0.11 の設計案

Fluentd v11 設計案

We made it possible. Next, we'll make it beautiful.

Suffering-oriented programming

コンセプト

  • 柔軟性向上
  • 予想以上に複雑な使い方をしているケースが多かったので、設定ファイルも複雑化して対応する
@frsyuki
frsyuki / fluentd-v11-design-label.md
Created May 9, 2012 23:37
Fluentd v11 内部ルーティングラベルの実装案あれこれ

Fluentd v11 内部ルーティングラベルの実装案あれこれ

Fluentd v11 設計案 の「1. 内部ルーティングラベルの導入」について、続き。

実装方法

案1. 新しいメタデータ「label」を導入する

  • プラグインは、emitするときにlabelを指定することができる(省略可能)
  • Engine.emit(tag, time, record[, label])
@fcicq
fcicq / smartmachine-survival-guide-fcicq.markdown
Last active December 11, 2015 06:48
SmartMachine 生存指南 by fcicq

SmartMachine 生存指南

by fcicq, CC-BY

SmartMachine 是 Joyent 家的虚拟化方案.
SmartOS 主要的卖点是 ZFS + DTrace + Zones (SmartMachine) + KVM (运行 Linux, Windows 等).
实际上 SmartOS 是 Joyent 以 Solaris 为基础 (因为 OpenSolaris 项目被中止而改名 illumos) 打包的操作系统.

SmartOS 作为 HOST 时, 虽然支持 KVM 虚拟化, 但不支持突发的 vCPU.
而 SmartMachine 是基于 Zones 的 (存储则是 ZFS), 比较类似 Linux 平台下 OpenVZ 或者 LXC 的方案.
资源用量由调度器决定, 只需要修改配额 (ZFS 也支持在线扩展) 就可以伸缩, 所以伸缩不需要重启.

@fcicq
fcicq / supervisord.conf
Created July 15, 2013 13:23
supervisord config for solaris (/opt/local/etc/supervisord.conf), may need to "mkdir -p /opt/local/etc/supervisor /var/log/supervisor" first
; supervisor config file
[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod=0700 ; sockef file mode (default 0700)
[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
#!/bin/env python
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
import tornado.httpclient
import tornado.gen
from tornado.concurrent import run_on_executor
from concurrent.futures import ThreadPoolExecutor
@zvyn
zvyn / maybe.py
Last active December 29, 2016 04:33 — forked from senko/maybe.py
# maybe.py - a Pythonic implementation of the Maybe monad
# Copyright (C) 2014. Milan Oberkirch <milan.py@oberkirch.org>
# Copyright (C) 2014. Senko Rasic <senko.rasic@goodcode.io>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions: