查看大文件时,Emacs有时会挂起.但它很快(global-font-lock-mode -1).
我正在使用Prelude的分支.
Emacs版本:24.3 cocoa系统:OS X 10.8.4
更新:我发现(setq jit-lock-defer-time 0.05)是一种提高滚动速度的方法.
Style 1:
a(X) when X>1 ->
...omitted;
a(X) when X ->
...omitted.
Run Code Online (Sandbox Code Playgroud)
Style 2
a(X) ->
case X>1 of
true-> ...ommited;
false-> ...ommited
end.
Run Code Online (Sandbox Code Playgroud)
====Update===
As @rviding said, I update the comparison as following:
Style 1:
a(X) when X>1 ->
...omitted;
a(X) ->
...omitted.
Run Code Online (Sandbox Code Playgroud)
Style 2
a(X) ->
case X>1 of
true-> ...ommited;
false-> ...ommited
end.
Run Code Online (Sandbox Code Playgroud)
我正在根据本文开发一个具有反向地理编码功能的iOS应用程序:地理编码教程
但是当我在模拟器上测试时,我得到'kCLErrorDomain错误9'.我搜索了很多,只有错误0或1而不是9.
这是我的代码viewDidLoad:
self.locationManager = [[CLLocationManager alloc]init];
self.locationManager.delegate = self;
self.locationManager.distanceFilter = 80.0;
[self.locationManager startUpdatingLocation];
CLGeocoder *geocoder = [[[CLGeocoder alloc] init] autorelease];
[geocoder reverseGeocodeLocation:self.locationManager.location
completionHandler:^(NSArray *placemarks, NSError *error) {
NSLog(@"reverseGeocodeLocation:completionHandler: Completion Handler called!");
if (error){
NSLog(@"Geocode failed with error: %@", error);
return;
}
if(placemarks && placemarks.count > 0)
{
//do something
CLPlacemark *topResult = [placemarks objectAtIndex:0];
NSString *addressTxt = [NSString stringWithFormat:@"%@ %@,%@ %@",
[topResult subThoroughfare],[topResult thoroughfare],
[topResult locality], [topResult administrativeArea]];
NSLog(@"%@",addressTxt);
}
}];
Run Code Online (Sandbox Code Playgroud)
非常感谢你.
Erlang ver:R16B
操作系统:Fedora17
erl -name a以及erl -sname a所有报告的以下错误:
{error_logger,{{2013,4,20},{14,50,20}},"Protocol: ~tp: register/listen error: ~tp~n",["inet_tcp",epmd_close]}
{error_logger,{{2013,4,20},{14,50,20}},crash_report,[[{initial_call,{net_kernel,init,['Argument__1']}},{pid,<0.21.0>},{registered_name,[]},{error_info,{exit,{error,badarg},[{gen_server,init_it,6,[{file,"gen_server.erl"},{line,320}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}]}},{ancestors,[net_sup,kernel_sup,<0.10.0>]},{messages,[]},{links,[#Port<0.56>,<0.18.0>]},{dictionary,[{longnames,true}]},{trap_exit,true},{status,running},{heap_size,376},{stack_size,27},{reductions,728}],[]]}
{error_logger,{{2013,4,20},{14,50,20}},supervisor_report,[{supervisor,{local,net_sup}},{errorContext,start_error},{reason,{'EXIT',nodistribution}},{offender,[{pid,undefined},{name,net_kernel},{mfargs,{net_kernel,start_link,[[s,longnames]]}},{restart_type,permanent},{shutdown,2000},{child_type,worker}]}]}
{error_logger,{{2013,4,20},{14,50,20}},supervisor_report,[{supervisor,{local,kernel_sup}},{errorContext,start_error},{reason,{shutdown,{failed_to_start_child,net_kernel,{'EXIT',nodistribution}}}},{offender,[{pid,undefined},{name,net_sup},{mfargs,{erl_distribution,start_link,[]}},{restart_type,permanent},{shutdown,infinity},{child_type,supervisor}]}]}
{error_logger,{{2013,4,20},{14,50,20}},crash_report,[[{initial_call,{application_master,init,['Argument__1','Argument__2','Argument__3','Argument__4']}},{pid,<0.9.0>},{registered_name,[]},{error_info,{exit,{{shutdown,{failed_to_start_child,net_sup,{shutdown,{failed_to_start_child,net_kernel,{'EXIT',nodistribution}}}}},{kernel,start,[normal,[]]}},[{application_master,init,4,[{file,"application_master.erl"},{line,138}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}]}},{ancestors,[<0.8.0>]},{messages,[{'EXIT',<0.10.0>,normal}]},{links,[<0.8.0>,<0.7.0>]},{dictionary,[]},{trap_exit,true},{status,running},{heap_size,376},{stack_size,27},{reductions,117}],[]]}
{error_logger,{{2013,4,20},{14,50,20}},std_info,[{application,kernel},{exited,{{shutdown,{failed_to_start_child,net_sup,{shutdown,{failed_to_start_child,net_kernel,{'EXIT',nodistribution}}}}},{kernel,start,[normal,[]]}}},{type,permanent}]}
{"Kernel pid terminated",application_controller,"{application_start_failure,kernel,{{shutdown,{failed_to_start_child,net_sup,{shutdown,{failed_to_start_child,net_kernel,{'EXIT',nodistribution}}}}},{kernel,start,[normal,[]]}}}"}
Crash dump was written to: erl_crash.dump
Kernel pid terminated (application_controller) ({application_start_failure,kernel,{{shutdown,{failed_to_start_child,net_sup,{shutdown,{failed_to_start_child,net_kernel,{'EXIT',nodistribution}}}}},{k
Run Code Online (Sandbox Code Playgroud)
以下是iptables:
> iptables --list
Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP icmp -- anywhere anywhere
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Run Code Online (Sandbox Code Playgroud)
以下是erl:
> erl
Erlang R16B (erts-5.10.1) [source] [smp:8:8] [async-threads:10] …Run Code Online (Sandbox Code Playgroud) 主管是一种 OTP 行为。
init([]) ->
RoomSpec = {mod_zytm_room, {mod_zytm_room, start_link, []},
transient, brutal_kill, worker, [mod_zytm_room]},
{ok, {{simple_one_for_one, 10, 10000}, [RoomSpec]}}.
Run Code Online (Sandbox Code Playgroud)
上面的代码将调用孩子的terminate方法。
但是,如果我将 更改brutal_kill为整数超时(例如 6000),terminate则永远不会调用该方法。
我在 Erlang 文档中看到了一个解释:
无论关闭策略如何,动态创建的简单一对一监督者的动态创建的子进程都不会被明确杀死,但预计会在监督者这样做时终止(即,当收到来自父进程的退出信号时)。
但我不能完全理解。是不是说exit(Pid, kill)可以终止simple_one_for_one子规范而exit(Pid, shutdown)不能?
======================================更新============== ======================
mod_zytm_room_sup.erl
-module(mod_zytm_room_sup).
-behaviour(supervisor).
-export([start_link/0, init/1, open_room/1, close_room/1]).
start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
init([]) ->
RoomSpec = {mod_zytm_room, {mod_zytm_room, start_link, []},
transient, brutal_kill, worker, [mod_zytm_room]},
{ok, {{simple_one_for_one, 10, 10000}, [RoomSpec]}}.
open_room(RoomId) ->
supervisor:start_child(?MODULE, [RoomId]).
close_room(RoomPid) …Run Code Online (Sandbox Code Playgroud) 我正在使用mongodb和redis,redis是我的缓存.
我用redis-py缓存mongodb对象:
obj in mongodb: {u'name': u'match', u'section_title': u'\u6d3b\u52a8', u'title':
u'\u6bd4\u8d5b', u'section_id': 1, u'_id': ObjectId('4fb1ed859b10ed2041000001'), u'id': 1}
Run Code Online (Sandbox Code Playgroud)
使用hgetall(key,obj)从redis获取的obj是:
{'name': 'match', 'title': '\xe6\xaf\x94\xe8\xb5\x9b', 'section_title':
'\xe6\xb4\xbb\xe5\x8a\xa8', 'section_id': '1', '_id': '4fb1ed859b10ed2041000001', 'id': '1'}
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,从缓存获取的obj是str而不是unicode,所以在我的应用程序中,有一个错误:'ascii'编解码器无法解码位置12中的字节0xe6:序数不在范围内(128)
谁能提出一些建议?感谢你
我想酿造 rm mtr 和它的 deps,所以我执行
brew rm mtr
brew rm $(join <(brew leaves) <(brew deps mtr))
Run Code Online (Sandbox Code Playgroud)
但它说This command requires a keg argument。什么是小桶论证?
谢谢你。
似乎功能gen_server:handle_cast/3和gen_server:handle_info/3非常相似.我知道这handle_info/3用于处理超时事件.
有没有其他规则可以使用它们?在我看来,我更喜欢handle_info/3用来处理异步消息.因为使用语法糖更短!.
我开始 2 个龙卷风实例,例如。tornado-8000 和 tornado-8001,使用上游 nginx。
当我在一个实例上插入数据时,在另一个实例上的查询找不到此数据。
SQLAlchemy 查询如下:
topics = self.db.query(Topic).order_by(Topic.updated_at.desc()).limit(20)
Run Code Online (Sandbox Code Playgroud)
我的 SQLAlchemy 初始化如下:
class Application(tornado.web.Application):
def __init__(self):
# setup app
from urls import handlers,ui_modules
settings = dict(
debug = options.debug,
static_path = os.path.join(root_dir, "static"),
xsrf_cookies = True,
cookie_secret = "nzjxcjasduuqwheazmu293nsadhaslzkci9023nsadnua9sdads/Vo=",
ui_modules = ui_modules,
)
tornado.web.Application.__init__(self, handlers, **settings)
self.db = scoped_session(sessionmaker(bind=engine,autocommit=False,autoflush=False))
Run Code Online (Sandbox Code Playgroud)
基处理程序:
class BaseHandler(web.RequestHandler):
@property
def db(self):
return self.application.db
Run Code Online (Sandbox Code Playgroud)
我的插入:
topic = Topic()
topic.title = u'abcdefg'
self.db.add(topic)
self.db.commit()
Run Code Online (Sandbox Code Playgroud)
错误在哪里?
以下代码在编译时给出警告:警告:使用运算符'>'无效
rd(a,{x,y}),
List = [#a{x=1,y=2}, #a{x=3,y=4}],
lists:filter(
fun(E) ->
E#a.x > 1, E#a.y =:= 2
end, List).
Run Code Online (Sandbox Code Playgroud)
但是当我用逗号代替逗号时,没有警告.
erlang ×5
python ×2
emacs ×1
erlang-otp ×1
homebrew ×1
ios ×1
redis ×1
sqlalchemy ×1
tornado ×1