Skip to content

Instantly share code, notes, and snippets.

View JoshuaChi's full-sized avatar

Joshua Chi JoshuaChi

View GitHub Profile
@JoshuaChi
JoshuaChi / jquery autocomplete stying
Created May 10, 2013 03:01
Inspired by demo(http://twitter.github.io/typeahead.js/examples/). Tested with "jQuery UI CSS Framework 1.8.14"
.ui-autocomplete {
position: absolute;
top: 100%;
left: 0;
right: auto;
z-index: 1000;
display: none;
min-width: 160px;
_width: 160px;
padding: 8px 0px;
[setattr(self, attr, opts.pop(attr)) for attr in ['refresh_token', 'expires_in', 'expires_at'] if opts.has_key(attr)]
/** Class: Strophe.WebSocket
* XMPP Connection manager.
*
* Thie class is the main part of Strophe. It manages a BOSH connection
* to an XMPP server and dispatches events to the user callbacks as
* data arrives. It supports SASL PLAIN, SASL DIGEST-MD5, and legacy
* authentication.
*
* After creating a Strophe.Connection object, the user will typically
* call connect() with a user supplied callback to handle connection level
brew update
brew versions FORMULA
cd `brew --prefix`
git checkout HASH Library/Formula/FORMULA.rb # use output of "brew versions"
brew install FORMULA
brew switch FORMULA VERSION
git checkout -- Library/Formula/FORMULA.rb # reset formula
## Example: Using Subversion 1.6.17
#
@JoshuaChi
JoshuaChi / statistics.erl
Created December 12, 2013 05:04
the code to analysis erlang process memory
%%%-------------------------------------------------------------------
%%% File : statistics.erl
%%% Author : whoppix <jwringstad@gmail.com>
%%% Description :
%%%
%%% Created : 26 Jul 2009 by <jwringstad@gmail.com>
%%%-------------------------------------------------------------------
-module(statistics).
-export([start/0, start_link/0, init/0, loop/0]).
-compile([export_all]).
bits(0, R)->
R;
bits(N, R) ->
B = N band ((bnot N) + 1),
bits(N bxor B, lists:append(R, [B])).
def bits(n):
    while n:
        b = n & (~n+1)
        yield b
        n ^= b
>>> for b in bits(109):
    print(b)
@JoshuaChi
JoshuaChi / binary replace
Last active December 31, 2015 22:19
binary replace takes too long to execute
byte_size(V).
599833
binary:replace(V, <<0>>, <<>>, [global]).
binary:part(V,{10, 1000}).
curl -XDELETE http://localhost:9200/ac-test
curl -XPUT http://localhost:9200/ac-test
curl -XPUT http://localhost:9200/ac-test/people/1 -d '
{
"firstNames" : "James Earl",
"lastName" : "Jones",
"location" : "Hollywood, CA"
}'
curl -XPUT http://localhost:9200/ac-test/people/2 -d '
If you want, I can try and help with pointers as to how to improve the indexing speed you get. Its quite easy to really increase it by using some simple guidelines, for example:
- Use create in the index API (assuming you can).
- Relax the real time aspect from 1 second to something a bit higher (index.engine.robin.refresh_interval).
- Increase the indexing buffer size (indices.memory.index_buffer_size), it defaults to the value 10% which is 10% of the heap.
- Increase the number of dirty operations that trigger automatic flush (so the translog won't get really big, even though its FS based) by setting index.translog.flush_threshold (defaults to 5000).
- Increase the memory allocated to elasticsearch node. By default its 1g.
- Start with a lower replica count (even 0), and then once the bulk loading is done, increate it to the value you want it to be using the update_settings API. This will improve things as possibly less shards will be allocated to each machine.
- Increase the number of machines you have so