What does “LC_ALL=C” do?

$ LC_ALL=es_ES man
¿Qué página de manual desea?
$ LC_ALL=C man
What manual page do you want?
$ LC_ALL=en_US sort <<< $'a\nb\nA\nB'
a
A
b
B
$ LC_ALL=C sort <<< $'a\nb\nA\nB'
A
B
a
b

Use PHP composer to clone git repo

DO YOU HAVE A REPOSITORY?

Git, Mercurial, SVN is supported by Composer.

DO YOU HAVE WRITE ACCESS TO THE REPOSITORY?

Yes?

DOES THE REPOSITORY HAVE A composer.json FILE

If you have a repository you can write to: Add a composer.json file, or fix the existing one, and DON’T use the solution below.

Go to @igorw ‘s answer

ONLY USE THIS IF YOU DON’T HAVE A REPOSITORY
OR IF THE REPOSITORY DOES NOT HAVE A composer.json AND YOU CANNOT ADD IT

This will override everything that Composer may be able to read from the original repository’s composer.json, including the dependencies of the package and the autoloading.

Using the package type will transfer the burden of correctly defining everything onto you. The easier way is to have a composer.json file in the repository, and just use it.

This solution really only is for the rare cases where you have an abandoned ZIP download that you cannot alter, or a repository you can only read, but it isn’t maintained anymore.

"repositories": [
    {
        "type":"package",
        "package": {
          "name": "l3pp4rd/doctrine-extensions",
          "version":"master",
          "source": {
              "url": "https://github.com/l3pp4rd/DoctrineExtensions.git",
              "type": "git",
              "reference":"master"
            }
        }
    }
],
"require": {
    "l3pp4rd/doctrine-extensions": "master"
}

忧愁上身 / 贾樟柯

有一年春节,我从北京回老家汾阳过年,电话里和一帮高中同学定下初四聚会。初四早晨,县城里有零星的鞭炮声。我一大早就醒来,开始洗澡换衣服,心乱,像去赴初恋约会。
又是一年不见,那些曾经勾肩搭背、横行乡里的春风少年,被时间平添了些陌生。到底是有牵挂,一干人围坐桌边,彼此客气,目光却死盯着对方。一个同学捧着菜单和服务员交涉,其余人假装礼貌选择沉默。包间里静极了,大家听他点菜,个个斯文得像上班主任的课。他们一口一口吸烟,我一眼一眼相望。可惜满目都是同窗好友老了的证据,想调侃几句,却一时找 不到合适的乡音。
还是酒厂搞推销的同学生猛,吐个烟圈后一下找到了高中时代看完黄色录像后的兴奋感,盯着我拷问道:贾导演,老实交代,今年你潜规则了几个? 青春虽走,荷尔蒙犹在。这话题让一屋子刚进中年早期的同学顿时焕发了青春。对我的“审讯”让所有人激动,我接受这莫须有的“冤案”,只为找回当年的亲近。就像高一时,他们捕获了我投向她的目光中的爱慕,在宿舍熄灯后杜撰着我和她的爱情,而我不选择辩白,夜夜在甜蜜的谣言中睡去。 今天,甜蜜已经不在。我被他们的“罚酒”搞得迅速醉倒,在酒精的炙烤中睡去。下午醒来,不知身处何处,耳边又传来同学们打牌赌博的声音,就闭眼听他们吵吵闹闹,像回到最初。记得高考前也有同样的一刻,我们这些注定考不上的差生破罐子破摔,高考在即却依旧麻将在手。有一天我躺在宿舍床上听着旁边的麻将声,想想自己的未来,心里突然一阵潮湿。十八岁前的日子清晰可见,之后的大片岁月却还是一整张白纸。我被深不见底的未来吓倒,在搓麻声中用被子拼命捂住自己,黑暗中我悄悄哭了。 那天没有人知道,他们旁边的少年正忧愁上身。
二十几年过去,县城里的老同学已经习惯了上酒店开房打牌。朦胧中我又听到了熟悉的麻将声,听他们讲县里的煤矿、凶杀、婚外恋,竟觉得自己日常乐趣太少,一时心里空虚。年少时总以为未来都会是闪亮的日子,虚荣过后才发现所有的记忆都会褪色。这时,又偷偷想了想自己的未来,未来于我却好像已经见底,一切一目了然。我为这一眼见底的未来伤感,心纠结成一片。
原来,人到中年竟然还会忧愁上身。
想一个人走走便起身出门,到院子里骑了同学的摩托车漫无目的地开了起来。不知不觉中我已经穿越县城,旁边车过卷起尘土,躲避过后才发现自己习惯地选择了那条村路。村路深处,暮霭中的山村有我曾经朝夕相处的同学。
他和我一样,第一年高考落榜了。我避走太原学画画,他没有复读又回了农村。以后的日子,见面越来越少。友情的火焰被乌黑坚硬的现实压住,大家没有告别便已各奔前程。“曾经年少爱追梦,一心只想往前飞”的这些年,一路上失散了多少兄弟,连我自己都搞不清楚。此时此地,我却站在了他的村口。以前县城里老停水,一停水我就拉一辆水车去他们村里拉水。每次都会在他家里小坐一会儿,那时候村里普遍还住土炕,或许他在县城读书受了影响,把一间窑洞的土炕拆了,自己生炉子搭床睡。床铺收拾得整整齐 齐,他的房间与周围环境相比,特殊得像一块租界。
我骑摩托车进了村,村里有些变化,街道结构却一切如旧。到了他家刻有“耕读之家”的大门口,一眼就看到院子里他的父母。我被他们“搀扶”着进了房间,热情过后才知道我的同学走亲戚去了。多年不见,他的房间竟然没有任何改变,甚至床单被罩,甚至一桌一椅。 “他还没有成家?”我问。
“没有。”他的父母齐声回答。
沉默中我环顾左右,突然在他的枕边发现了一本书,那是80年代出版的一册杂志《今古传奇》,对,就是前边几篇侦探小说,最后《书剑恩仇录》的那本。这册《今古传奇》上高中的时候从一个同学手里传递到另一个同学手里。这本书在教室里传来递去,最后到了他的手里,直到现在还躺在他的枕边。这二十几年,日日夜夜,他是不是翻看着同样一册小说?一
种“苦”的味道涌上心头,一个又一个漫长的山村之夜,他是不是就凭这一册《今古传奇》挺了过来?我一个人骑摩托返城,山边星星衬托着乡村的黑夜,这里除了黑还是黑。我突然想,在这一片漆黑的夜里,他会不会也和我一样经常忧愁上身? 春节过后回了北京,又好像和那片土地断了联系。不久之后,一次又一次的“富士康”事件让我瞠目结舌。我和他们来自同一种贫穷,我和他们投入的是同一种不公。我们有相同的来路,我相信我了解他们的心魔,那一刹那他们慌不择路,那一刹那他们忧愁上身。
可是,我们又能做些什么呢?我想起我忧愁上身的时候,我用被子捂着脸哭的时候,其实特别需要有人和我聊聊。那就拍部片子吧,找那些已经走出一片天的过来人,谈谈他们生命中最黑暗的时刻,聊聊他们走出艰难岁月的智慧和勇气。后来,我找到六位年轻的导演一起合作,我们拍摄了十二位人士,拍出了十二部短片,影片的名字叫《语路》。
感谢影片中来自商业、艺术、公益领域的十二位人物慷慨的讲述,感谢他们以金玉良言相送。还要感谢苏格兰威士忌尊尼获加金玉相送,他们发起 和投资了这次“语路计划”,让我们的“问道”之旅得以实现。
我常常会会想起过去,想起我们各奔前程的青春往事。可是,同处这个世界,我们真的能彼此不顾,各奔前程吗?
继续阅读“忧愁上身 / 贾樟柯”

js appy call

The difference is that apply lets you invoke the function with arguments as an array; call requires the parameters be listed explicitly. A useful mnemonic is “A for array and C for comma.”

See MDN’s documentation on apply and call.

Pseudo syntax:

theFunction.apply(valueForThis, arrayOfArgs)

theFunction.call(valueForThis, arg1, arg2, …)

There is also, as of ES6, the possibility to spread the array for use with the call function, you can see the compatibilities here.

Sample code:

function theFunction(name, profession) {
    console.log("My name is " + name + " and I am a " + profession + ".");
}
theFunction("John", "fireman");
theFunction.apply(undefined, ["Susan", "school teacher"]);
theFunction.call(undefined, "Claude", "mathematician");
theFunction.call(undefined, ...["Matthew", "physicist"]); // used with the spread operator

// Output: 

// My name is John and I am a fireman.
// My name is Susan and I am a school teacher.
// My name is Claude and I am a mathematician.
// My name is Matthew and I am a physicist.

Java元编程

类加载
http://tutorials.jenkov.com/java-reflection/dynamic-class-loading-reloading.html

Java元编程
https://www.quora.com/Is-it-possible-to-do-metaprogramming-in-Java
http://stackoverflow.com/questions/8387506/java-static-metaprogramming/43671019#43671019
http://stackoverflow.com/questions/8868102/java-metaprogramming
http://stackoverflow.com/questions/112320/is-static-metaprogramming-possible-in-java

lombok
http://notatube.blogspot.hk/2010/12/project-lombok-creating-custom.html
http://notatube.blogspot.com/2010/11/project-lombok-trick-explained.html
http://stackoverflow.com/questions/6107197/how-does-lombok-work

热加载
https://my.oschina.net/xianggao/blog/364068
Annotation Processing
http://hannesdorfmann.com/annotation-processing/annotationprocessing101
https://github.com/google/auto

代码生成
https://github.com/square/javapoet

字节码增强
http://www.infoq.com/cn/articles/cf-java-byte-code

Deploy the Jupyter Notebook container on VPS and use Nginx as the reverse proxy

# /etc/nginx/sites-enabled/some.domain
# Change the server name {some.domain}
# Change the {host.of.notebook} and {port} in the following locations
server {
        listen 80;
        # Change the server name {some.domain}
        server_name some.domain;
        location / {
                # Change the {host.of.notebook} and {port}
                proxy_pass http://host.of.notebook:port;

                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_read_timeout 86400;
        }

        client_max_body_size 50M;
        error_log /var/log/nginx/error.log;

        location ~* /(api/kernels/[^/]+/(channels|iopub|shell|stdin)|terminals/websocket)/? {
                # Change the {host.of.notebook} and {port}
                proxy_pass http://host.of.notebook:port;

                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header Host $host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

                proxy_http_version 1.1;

                #proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Upgrade "websocket";
                proxy_set_header Connection "upgrade";
                proxy_read_timeout 86400;
        }

}

linux下批量删除空文件(大小等于0的文件) 和 乱码文件

find . -name "*" -type f -size 0c | xargs -n 1 rm -f

用这个还可以删除指定大小的文件,只要修改对应的 -size 参数就行,例如:

find . -name "*" -type f -size 1024c | xargs -n 1 rm -f

就是删除1k大小的文件。(但注意不要用 -size 1k,这个得到的是占用空间1k,不是文件大小1k的)。

如果只要删除文件夹或者名字连接等,可以相应的改 -type 参数,具体细节见 man find 。

继续阅读“linux下批量删除空文件(大小等于0的文件) 和 乱码文件”

pip使用豆瓣的镜像源

easy_install -i http://pypi.douban.com/simple/ ipython
pip install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com/simple ipython
pip  install  -i  https://pypi.doubanio.com/simple/  --trusted-host pypi.doubanio.com  django