易栈网-膘叔

浏览模式: 标准 | 列表 | 图文
多说也要关闭了

多说也要关闭了

昨天各路消息中都有一条:多说要停止服务了。

这两年很多公司都开始放弃一些不赢利的服务,比如:简聊、360的前端库,这些既要投入人又要投入精力的,慢慢的都开始放弃了。估计以后也只会有一些大学才会做这些非赢利的事儿了,就象中科大的镜像源(其他他不要被关掉)。
大公司天天说我们要开源,我们要回馈社会,但终究不能坚持,这突然让我想起小时候我老爸一直念叨的话,他说老毛说过:做好事并不难,难的是一辈子做好事。这句话,用在现在的互联网时代真心可以。
附上邮件截图:
就象我博客的底部留的那句话:又有谁的博客永久消失了?
从博客有第一篇开始,很多朋友都过来说加个友情链接吧,到现在为止,这些活着的链接已经不到5分之1了。
坚持,果然是最难的事情。
中文地址翻译成英文地址方法和技巧

中文地址翻译成英文地址方法和技巧

纯粹是因为要申请邓白氏编码的时候用到。做个记录,中文从大到小,英文从小到大。有些词还是看一下。[更新]

中文地址的排列顺序是由大到小,如:X国X省X市X区X路X号,而英文地址则刚好相反,是由小到大。如上例写成英文就是:X号,X路,X区,X市,X省,X国。掌握了这个原则,翻译起来就容易多了!
X室 Room X
X号 No. X
X单元 Unit X
X号楼 Building No. X
X街 X Street
X路 X Road
X区 X District
X县 X County
X镇 X Town
X市 X City
X省 X Province
请注意:翻译人名、路名、街道名等,最好用拼音。
中文地址翻译范例:
宝山区示范新村37号403室
Room 403, No. 37, SiFang Residential Quarter, BaoShan District
虹口区西康南路125弄34号201室
Room 201, No. 34, Lane 125, XiKang Road(South), HongKou District
473004河南省南阳市中州路42号 李有财
Li Youcai
Room 42
Zhongzhou Road, Nanyang City
Henan Prov. China 473004
434000湖北省荆州市红苑大酒店 李有财
Li Youcai
Hongyuan Hotel
Jingzhou city
Hubei Prov. China 434000
473000河南南阳市八一路272号特钢公司 李有财
Li Youcai
Special Steel Corp.
No. 272, Bayi Road, Nanyang City
Henan Prov. China 473000
528400广东中山市东区亨达花园7栋702 李有财
Li Youcai
Room 702, 7th Building
Hengda Garden, East District
Zhongshan, China 528400
361012福建省厦门市莲花五村龙昌里34号601室 李有财
Li Youcai
Room 601, No. 34 Long Chang Li
Xiamen, Fujian, China 361012
361004厦门公交总公司承诺办 李有财
Mr. Li Youcai
Cheng Nuo Ban, Gong Jiao Zong Gong Si
Xiamen, Fujian, China 361004
266042山东省青岛市开平路53号国棉四厂二宿舍1号楼2单元204户甲 李有财
Mr. Li Youcai
NO. 204, A, Building NO. 1
The 2nd Dormitory of the NO. 4 State-owned Textile Factory
53 Kaiping Road, Qingdao, Shandong, China 266042
名片英语之地址英译
1、地址综述 名片的主要功能是通联,所以在名片上写上详细的家庭或单位通讯地址是必不可少的。
如下例:住址:浙江省台州市黄岩区天长路18号201室翻译成英文就是:Address: Room 201, 18 Tianchang Road, Huangyan District, Taizhou City, Zhejiang Province.对照上例,翻译时有几点需要注意:中文地址的排列顺序是由大到小: 国 柿市 区 路 号,而英文地址则刚好相反,是由小到大: 号 路(Road), 区(District), 市(City), 省(Province), 国。
地名专名部分(如”黄岩区”的”黄岩”部分)应使用汉语拼音,且需连写,如Huangyan不宜写成 Huang Yan。
各地址单元间要加逗号隔开。
以上给出了地点翻译的书写规则。接下去就地址内容进行详细分析。
完整的地址由:行政区划+街区名+楼房号三部分组成。
2、行政区划英译 行政区划是地址中最高一级单位,我国幅员辽阔,行政区划较复杂,总体上可分成五级(括号内所注为当前国内通用译名):
    • 1)国家(State):中华人民共和国(the People’s Republic of China; P.R.China; P.R.C; China)
    • 2)省级(Provincial Level):省(Province)、自治区(Autonomous Region )、直辖市(Municipality directly under the Central Government,简称Municipality);特别行政区(Special Administration Region; SAR)
    • 3)地级(Prefectural Level):地区(Prefecture)、自治州(Autonomous Prefecture)、市(Municipality;City);盟(Prefecture);
    • 4)县级(County Level):县(County)、自治县(Autonomous County)、市(City)、市辖区(District),旗(County)
    • 5)乡级(Township Level):乡(Township)、民族乡(Ethnic Township)、镇(Town)、街道办事处(Sub-district)。
PhpStorm中因为JS版本低而提示错误的解决

PhpStorm中因为JS版本低而提示错误的解决

开发项目的时候,发现:

这是提示我,当前Javascript版本不支持

打开phpstorm的设置,进行语言和框架设置,选中Javascript,将版本设置为ECMAScript6。

保存一下,再看刚才的文件,提示已经没有了
由于以前只是用JS写写常用的东西,也没有注意过。果然使用ECMAScript6。虽然 VSCode什么的也可以,但切换来切换去的,总觉得不方便,而且这个设置只对当前项目有用,就先这么处理吧
Laravel action helper函数用法

Laravel action helper函数用法

原本以为是很简单的一个用法。

action('XxxxController@test',['abc'=>1]);
结果,不仅仅是这样的,
如果你的XxxxController@test,没有在router里定义过。会直接报错,报:App\Http\Controller\XxxController@test 不存在,虽然 你很明确的知道它就在那里!
原来我 写URL的时候都是直接写 url('abc/def'),其实应该用action('xxxcontroller@def'),好处是,action是可以带参数的。url你永远带不进参数!!!
纯记录。NND
Lumen启动时出现:NotFoundHttpException

Lumen启动时出现:NotFoundHttpException

Lumen在初次安装好启动的时候,访问会出现:NotFoundHttpException

找了一下原因,在stackoverflow上有很多人提出来。常见的有这两种:在public/index.php里修改最后的$app->run();

  1. $app->run($app->make('request'));
  2. $app->run(Illuminate\Http\Request::capture());
如果用第1种,那你会发现所有的路由都被"/"解析了。你随便在URL里输入啥,都只会进入$app->get("/")这个路由
只有第二种才是正确的。
记录一下,参考 :
1、http://stackoverflow.com/questions/29728973/notfoundhttpexception-with-lumen
2、http://stackoverflow.com/questions/36436967/just-installed-lumen-and-got-notfoundhttpexception
买了台阿里云的内网(二)

买了台阿里云的内网(二)

接上一篇:买了台阿里云的内网 的内容

上一篇中,我采用了nginx来转发http代理 的请求,但这里有个问题就是,如果你要请求的是https的数据,上面的配置就不方便了
于是祭出了ssh -D 大法,在内网里使用ssh -D xxxx 公网IP 。然后使用polipo来设置成http_proxy和https_proxy代理
polipo安装很简单:apt-get install polipo
修改/etc/polipo/config,加入两行
socksParentProxy = localhost:上面的xxx
socksProxyType = socks5
再将~/.bashrc中的http_proxy改为 http_proxy=127.0.0.1:8123 (8123是polipo的默认端口),再加一条https_proxy,数据一样
只是ssh -D ,会连接上远程服务器,有点麻烦。总不能不关窗口吧?再祭出screen。于是都解决了
screen -S sshd
然后ctrl+a d 退出来就OK了
再试着请求wget https://getcomposer.org/installer,顺利下载并安装好
----EOF---
后记:如果你不请求https数据,那么用nginx就够了。
买了台阿里云的内网

买了台阿里云的内网

几个小笔记,自己处理一下

10.171.x.x 是外网机器 的内网IP
10.29.x.x 是内网机器 的IP
#在外网机器上加入这些iptables
iptables -t nat --flush
iptables -t nat -A PREROUTING -p tcp --dport 2222 -j DNAT --to-destination 10.29.x.x:22
iptables -t nat -A POSTROUTING -d 10.29.x.x -p tcp --dport 22 -j SNAT --to 10.171.x.x
iptables-save > /etc/iptables.up.rules
echo "pre-up iptables-restore < /etc/iptables.up.rules" > /etc/network/interface
--------上面这段是支持直接用2222端口连接入内网
在外网机器 的nginx加入以下配置,设置HTTP代理
server {
listen 9999 ;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
resolver 114.114.114.114;
proxy_pass http://$http_host$request_uri;
}
}
----------
在内网机器里加入:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export http_proxy=http://10.171.212.249:9999
修改:/etc/apt/source.list 为 ustc.edut.cn的源
deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian stable main contrib non-free
deb http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free
# deb http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free
deb http://mirrors.ustc.edu.cn/dotdeb jessie all
deb-src http://mirrors.ustc.edu.cn/dotdeb jessie all
------------
添加了dotdeb的源后,需要处理一下(官网是https,其实也支持http)
wget http://www.dotdeb.org/dotdeb.gpg
cat dotdeb.gpg | apt-key add -
--------
至此,全部完成。由于有http_proxy,现在curl/wget,默认都可以用代理 了。只是https的不行。先这样了
Xcode “Device Locked” When iPhone is unlocked

Xcode “Device Locked” When iPhone is unlocked

When I tried to build and run, Xcode said my device was locked. I looked at my iPhone, and it's not locked at all....possible bug? How do I fix this?

1.Did you by chance not "trust" the device? This will prevent it from communicating with xcode even if the device is unlocked.

2.Unplug the device, close xcode, and then open xcode and plugin the device. When you plug it in (after unlocking it) it you should be prompted to "trust" the computer (in the iOS device). My guess is you may have accidentally tapped "do not trust" and so the device will refuse to connect to the computer.
3.Lock the device,Remove cable from device.,Unlock the device,Connect again to Mac
jquery的nestable组件在点击时如何不被拖动

jquery的nestable组件在点击时如何不被拖动

nestable在点击的时候,有一个拖动的状态被触发,会导致你给nestable上加的链接都会无效。

只要在最外层的li里加入一个class为:dd-nodrag,就不会被触发了。然后你在子菜单中就可以为它们加入工具菜单了,比如编辑 、删除等。
又或者,你加入dd-handle,这样的话,只能点击最左侧的handle部位才能被拖动
参考 :http://dbushell.github.io/Nestable/ 最下面
laravel mass update can not fire any events

laravel mass update can not fire any events

一个很简单的laravel代码:

User::where('id',1)->update(['last_login'=>time()]);
这样一个简单的代码,你会发现,它并没有触发:updating,updated事件,然而,你又会发现,updated_at也更新了。这是怎么回事?
跟进代码看一下,你会发现这个update,是Eloquent\Builder的方法,它的update方法代码很简单:
/**
* Update a record in the database.
*
* @param array $values
* @return int
*/
public function update(array $values)
{
return $this->toBase()->update($this->addUpdatedAtColumn($values));
}
我擦 ,要不要这么直接?再看一下toBase,这回是调用的是Query\Builder了。这里的update,就纯粹是生成sql,然后execute,不再走EloquentORM的事件了,所以就不会触发任何事件。
那么要怎么样才能触发事件呢?方法有两种
1、不要这样简写:先读数据再update,就一定会触发
2、不要用where(),而是直接User::find(1)->update([]),这时候就会从ORM走了。
这事儿官方有解释:
When issuing a mass update via Eloquent, the saved and updated model events will not be fired for the updated models. This is because the models are never actually retrieved when issuing a mass update.
同时,这事儿在stackoverflow上也有很多人在问,有人回复的就是和我上面的一样:
You need to retrieve the user from the database and then save that user in order to fire the event. For example:

This will NOT fire the update event:

User::where('id', $id)->update(['username' => $newUsername]);
This will fire the update event:

User::find($id)->update(['username' => $newUsername]);
官方的解释我是看过了,下面的是我用了很多办法没法解决后才找到的。
我在想,use SoftDeletes可以注入代码,为什么我不行?直到我发现softdeletes是官方自带库,人家都准备了事件:onDelete了。。怎么就没有onUpdate事件可以让我加点字段呢?
然后我又想用其他的Scope,也没有成功(折腾了一个下午)
暂时放弃!就这样吧,不过我还在想想,有没有什么办法可以注入,因为在sql生成完后,它还是有触发的事件的,比如:
/**
* Log a query in the connection's query log.
*
* @param string $query
* @param array $bindings
* @param float|null $time
* @return void
*/
public function logQuery($query, $bindings, $time = null)
{
if (isset($this->events)) {
$this->events->fire(new Events\QueryExecuted(
$query, $bindings, $time, $this
));
}

if ($this->loggingQueries) {
$this->queryLog[] = compact('query', 'bindings', 'time');
}
}

/**
* Register a database query listener with the connection.
*
* @param \Closure $callback
* @return void
*/
public function listen(Closure $callback)
{
if (isset($this->events)) {
$this->events->listen(Events\QueryExecuted::class, $callback);
}
}

/**
* Fire an event for this connection.
*
* @param string $event
* @return void
*/
protected function fireConnectionEvent($event)
{
if (! isset($this->events)) {
return;
}

switch ($event) {
case 'beganTransaction':
return $this->events->fire(new Events\TransactionBeginning($this));
case 'committed':
return $this->events->fire(new Events\TransactionCommitted($this));
case 'rollingBack':
return $this->events->fire(new Events\TransactionRolledBack($this));
}
}
实在不行了,还可以在事务上面想想办法,但是总归是只能一次处理,如果是需要两次执行sql。那还不如直接写代码呢。等有空再看了