https://github.com/SamuraiT/mecab-python3
http://mecab.googlecode.com/svn/trunk/mecab/doc/index.html
https://github.com/Christoph-D/Japanese-Tools/
Mar 4, 2015
Feb 25, 2015
Run many services on same server
If a service goes wrong, using 100% -> server is unresponsive, down!
To address this, I finally found:
cgroups: Control CPU/Mem resources for group of process
https://wiki.archlinux.org/index.php/cgroups
nice, cpulimit: Control CPU utilization level.
coreos + docker -> everything will be under measured.
To address this, I finally found:
cgroups: Control CPU/Mem resources for group of process
https://wiki.archlinux.org/index.php/cgroups
nice, cpulimit: Control CPU utilization level.
coreos + docker -> everything will be under measured.
Jan 30, 2015
Open big files in Komodo
Although Komodo is great, it will be broken on big files. The reason is costly syntax highlight.
Big files can be: too many lines; or big filesize.
To overcome this, create and run this macro "once".
After running, it will be persisted as a preference.
My setting is 200Kb and 5000 lines limit : )
Big files can be: too many lines; or big filesize.
To overcome this, create and run this macro "once".
After running, it will be persisted as a preference.
My setting is 200Kb and 5000 lines limit : )
// Let Komodo able to open big files by disable Syntax Highlight
var gprefs = Components.classes["@activestate.com/koPrefService;1"].
getService(Components.interfaces.koIPrefService).prefs;
gprefs.setLongPref("documentByteCountThreshold", 200000);
gprefs.setLongPref("documentLineCountThreshold", 5000);
alert('All was set. Openning big files is OK right now');
Jan 29, 2015
Ruby notes
Learn Ruby language via style guide is interesting
https://github.com/bbatsov/ruby-style-guide
Goodies:
http://docs.ruby-lang.org/en/2.2.0/Enumerable.html
http://docs.ruby-lang.org/en/2.2.0/syntax/modules_and_classes_rdoc.html
https://github.com/bbatsov/ruby-style-guide
Goodies:
http://docs.ruby-lang.org/en/2.2.0/Enumerable.html
http://docs.ruby-lang.org/en/2.2.0/syntax/modules_and_classes_rdoc.html
My discoveries:
print : echo bare text
p: print object as it as, with new line
puts: echo text with new line
alias create alias for existing method, var
ensure always executed at block termination
block comment
=begin
=end
undef remove function definition
convention:
Eg: eql?
method with a question mark return a bool value
Eg: delete! (bang symbol)
method with exclamation ! indicates that it's destructive: change object than a copy
Eg: name=
method ends with = is a setter
block can be wrapped by "do .. end" or { }
run by "yield"
Check for existence via if block_given?
:symbol
storage optimized string
Global names is from Kernel module
replace string once:
string['search']= 'replace'
replace all
string.gsub 'search', 'replace'
regex
string[/regex/]
regex replace uses the same syntax
string.split(/, /) you might guess
Object methods:
obj.to_s
obj.class
string.to_sym -> :symbol
num_string.to_i -> integer
range.to_a -> array
%w[ string1, ... ]
%i [ symbol1, ...]
[num1, ... ]
array << x # Add x to array (immuttable)
set operator: intersect &, diffeence -, union |
array.join sep
array.shift
Hash.new(default_value)
hash.key?
hash.value?
hash.keys
hash.values
Gem gotcha
If your local machine's hostname is set to your name, you will likely hit a trouble while installing gem:
"your-dns-needs-immediate-attention"
That's all I know. That message is oversay!
What to do is: set your hostname to a real top-level domain.
If it's a local machine, set it to "your-name.local"
Bold characters must be exactly typed!
"your-dns-needs-immediate-attention"
That's all I know. That message is oversay!
What to do is: set your hostname to a real top-level domain.
If it's a local machine, set it to "your-name.local"
Bold characters must be exactly typed!
# Linux
hostname -s your-name.local
# Mac OSX
scutil --set HostName your-name.local
Dreamy app stack
If choosing my own stack, I will choose:
- Python: Beauty, simple, powerful. It's slow but productive. Anything has tradeoff ; )
Framework: Tornado
- Cassandra: Autoscale, SQL-like query, Fast write, able to tune consistency: What can I ask more for a database!
- WeedFS: Distribute storage.
- Python: Beauty, simple, powerful. It's slow but productive. Anything has tradeoff ; )
Framework: Tornado
- Cassandra: Autoscale, SQL-like query, Fast write, able to tune consistency: What can I ask more for a database!
- WeedFS: Distribute storage.
Jan 26, 2015
Find PHP bottleneck!
There are many ways, such as Xhprof. However, because I already had Xdebug I will use Xdebug to profile the app; and setup Xdebug seems easier than Xhprof.
1. First set these in .htaccess (or php.ini)
2. Make sure that /var/xdebug/ is writable by web app, or change it to your folder.
3. Run the request to benchmark.
4. Each request will result in a new file /var/xdebug/cachegrind.out.NNNN
5. To read these stats needs brew install qcachegrind on Mac OSX, or kcachegrind on Linux.
After installing them, run, eg: qcachegrind /var/xdebug/cachegrind.out.NNNN
6. Examine by clicking on "self" column; consider function that take longest time. Well from here we need to think about what caused these bottlenecks.
1. First set these in .htaccess (or php.ini)
php_value xdebug.profiler_enable 1 php_value xdebug.profiler_output_dir "/var/xdebug/"
2. Make sure that /var/xdebug/ is writable by web app, or change it to your folder.
3. Run the request to benchmark.
4. Each request will result in a new file /var/xdebug/cachegrind.out.NNNN
5. To read these stats needs brew install qcachegrind on Mac OSX, or kcachegrind on Linux.
After installing them, run, eg: qcachegrind /var/xdebug/cachegrind.out.NNNN
6. Examine by clicking on "self" column; consider function that take longest time. Well from here we need to think about what caused these bottlenecks.
Subscribe to:
Posts (Atom)
