Skip to content

Instantly share code, notes, and snippets.

@peterli888
peterli888 / gist:5e0cd679ed6ae52b4f4d
Last active March 8, 2016 07:20
node-postgresql error
1.Connection.prototype.attachListeners 里面 self.emit(msg.name, msg); 应该try {}catch(e){} 包起来
2.Client.prototype.connect 里面 con.on('error', function(error) -> return self.emit('error', error); 不能 return
3.这两个地方可以在任意一个地方try 或者 process.on('uncaughtException', function(err){}),否则 连上又断的时候导致process crash
4.client.on('error',,,
client.connect(function(){}) 可能导致on的error收不到
5.DeAsync.js 对 seneca.http可行 对 seneca.tcp不行 可能原因是tcp的pipe代理等的问题
@peterli888
peterli888 / gist:e2f193fdeb4da6c9a1254f81adc64332
Created July 21, 2016 08:12
如何更好地跟踪匿名函数的错误
from: https://github.com/montagejs/mr/blob/master/browser.js
// Here we use a couple tricks to make debugging better in various browsers:
// TODO: determine if these are all necessary / the best options
// 1. name the function with something inteligible since some debuggers display the first part of each eval (Firebug)
// 2. append the "//# sourceURL=location" hack (Safari, Chrome, Firebug)
// * http://pmuellr.blogspot.com/2009/06/debugger-friendly.html
// * http://blog.getfirebug.com/2009/08/11/give-your-eval-a-name-with-sourceurl/
// TODO: investigate why this isn't working in Firebug.
// 3. set displayName property on the factory function (Safari, Chrome)
Write After End error in node.js webserver
you need do sth
if(!res || !res.status || !res.socket || !res.socket.readable)return;
or next()
or 在回调函数前加 return
or 把 response 作为参数传递给其他函数
@peterli888
peterli888 / pgjson.upsert
Created December 13, 2016 19:37
pgjson.upsert
CREATE OR REPLACE FUNCTION pgjson.upsert(
key text,
data jsonb)
RETURNS void AS
$BODY$
BEGIN
LOOP
UPDATE pgjson.main SET doc = data WHERE id = key;
IF found THEN
RETURN;
@peterli888
peterli888 / express.js single instance
Last active December 16, 2016 18:53
express.js single instance
in express.js
var global_app;
function createApplication(ifglobal) {
if(ifglobal && global_app){
return global_app;
}
var app = function(req, res, next) {
app.handle(req, res, next);
};
@peterli888
peterli888 / core.deltaBaseCacheLimit=2g 错误
Last active March 16, 2024 01:55
编译 v8 错误 core.deltaBaseCacheLimit=2g
编译 v8 core.deltaBaseCacheLimit=2g 错误
修改 depot_tools/gclient_utils.py
return '512m'
@peterli888
peterli888 / gist:1f73078eaf77dfb41adfc3080d8ff3e6
Last active March 3, 2017 07:20
debian下 pg_upgrade 升级 postgresql
ps -ef|grep postgres
sudo apt install postgresql-9.6
sudo /etc/init.d/postgresql stop
检查
修改/etc/postgresql/9.5/main/pg_hba.conf,确保本机信任访问
local   all   postgres   peer
修改/etc/postgresql/9.6/main/pg_hba.conf,确保本机信任访问
titanium_mobile-master\android\titanium\src\java\org\appcelerator\titanium\util\TiUIHelper.java
import java.io.File;//liyong
line-432 before
} catch (IOException e) {"Unable to load 'fonts' assets. Perhaps doesn't exist? "
//liyong
File f = null;
f = context.getDir("appdata",0);
tiapp.xml
<property name="ti.android.root.actas.launcher" type="bool">true</property>下面用到作为判断
<property name="ti.android.root.reappears.restart" type="bool">false</property>这个在ti代码里面查得到
<activity
android:configChanges="keyboardHidden|orientation"
android:label="Lyapp上升"
android:name=".LyappActivity" android:theme="@style/Theme.Titanium"
android:screenOrientation="nosensor"
android:excludeFromRecents="false"
android:resumeWhilePausing="false"
apt install -t jessie-backports openjdk-8-jre-headless ca-certificates-java