话说这个方法 search_with_prefix
是不是应该叫 fuzzy_search
..
这不是 prefix_search 啊..
[7] pry(main)> t.search_with_prefix 'AC' do |_, id|
[7] pry(main)* puts id
[7] pry(main)* end
1
1
3
2
每个字符串不应该 search 两次?还是这才是正确的行为。
[2] pry(main)> require "triez"
=> true
[3] pry(main)> t = Triez.new suffix: true
=> #<Triez:0x007f88cc936ff0>
[4] pry(main)> sequences = {
[4] pry(main)* 'ACTGAAAAAAACTG' => 1,
[4] pry(main)* 'ATACGGTCCA' => 2,
[4] pry(main)* 'GCTTGTACGT' => 3
[4] pry(main)* }
=> {"ACTGAAAAAAACTG"=>1, "ATACGGTCCA"=>2, "GCTTGTACGT"=>3}
[5] pry(main)> sequences.each do |seq, id|
[5] pry(main)* t[seq] = id
[5] pry(main)* end
=> {"ACTGAAAAAAACTG"=>1, "ATACGGTCCA"=>2, "GCTTGTACGT"=>3}
[6] pry(main)> t.search_with_prefix 'CGGT' do |_, id|
[6] pry(main)* puts id #=> 2
[6] pry(main)* end
2
#1 楼 @hooopo #2 楼 @whitecrow #3 楼 @fleuria
我谨代表 @luikore 鄙视你们这些 Mark 党..
› gem i triez
Fetching: triez-0.1.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing triez:
ERROR: Failed to build gem native extension.
/Users/saito/.rvm/rubies/ruby-1.9.3-p374/bin/ruby extconf.rb
creating Makefile
/usr/local/bin/gcc-4.2 -O3 -c -I.. ../hat-trie/ahtable.c ../hat-trie/hat-trie.c ../hat-trie/murmurhash3.c
In file included from ../hat-trie/ahtable.h:28,
from ../hat-trie/ahtable.c:8:
../hat-trie/pstdint.h:711: error: conflicting types for ‘uintptr_t’
/usr/include/i386/types.h:109: error: previous declaration of ‘uintptr_t’ was here
../hat-trie/pstdint.h:712: error: conflicting types for ‘intptr_t’
/usr/include/i386/types.h:105: error: previous declaration of ‘intptr_t’ was here
In file included from ../hat-trie/ahtable.h:28,
from ../hat-trie/hat-trie.c:9:
../hat-trie/pstdint.h:711: error: conflicting types for ‘uintptr_t’
/usr/include/i386/types.h:109: error: previous declaration of ‘uintptr_t’ was here
../hat-trie/pstdint.h:712: error: conflicting types for ‘intptr_t’
/usr/include/i386/types.h:105: error: previous declaration of ‘intptr_t’ was here
In file included from ../hat-trie/murmurhash3.h:7,
from ../hat-trie/murmurhash3.c:4:
../hat-trie/pstdint.h:711: error: conflicting types for ‘uintptr_t’
/usr/include/i386/types.h:109: error: previous declaration of ‘uintptr_t’ was here
../hat-trie/pstdint.h:712: error: conflicting types for ‘intptr_t’
/usr/include/i386/types.h:105: error: previous declaration of ‘intptr_t’ was here
ar -r libtries.a
ar: no archive members specified
usage: ar -d [-TLsv] archive file ...
ar -m [-TLsv] archive file ...
ar -m [-abiTLsv] position archive file ...
ar -p [-TLsv] archive [file ...]
ar -q [-cTLsv] archive file ...
ar -r [-cuTLsv] archive file ...
ar -r [-abciuTLsv] position archive file ...
ar -t [-TLsv] archive [file ...]
ar -x [-ouTLsv] archive [file ...]
make
compiling hat-stub.c
compiling triez.cc
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
linking shared-object triez.bundle
ld: library not found for -ltries
collect2: ld returned 1 exit status
make: *** [triez.bundle] Error 1
Gem files will remain installed in /Users/saito/.rvm/gems/ruby-1.9.3-p374/gems/triez-0.1 for inspection.
Results logged to /Users/saito/.rvm/gems/ruby-1.9.3-p374/gems/triez-0.1/ext/gem_make.out
mao
这是个好姿势, 你以后要常摆.
#22 楼 @ranmocy 如果没记错的话,在 Thin 上是不行的。用 unicorn 部署是没问题的。
我的 grack 主要是在 gitlabhq 里面实现 valid? 方法的时候用到了,主要是为了实现 gitlabhq 的权限控制。
如果没有分支权限问题的话,是不需要获取头的。https://github.com/gitlabhq/gitlabhq/blob/master/lib/gitlab/backend/grack_auth.rb#L76-L85
其实小明如果能把每天扔到自己身上的屎都收集起来,做深入研究。就能知道邻居一家身体状况。大便要是带血的话,痔疮,肛瘘,直肠癌各三成怕是无误了。
有一天小明穿着你最漂亮的衣服去上学
我觉得这个小明很有问题:穿我的衣服干嘛,穿他自己的啊。
#14 楼 @hooopo 实际上 Rails 一直以来都有两个问题是比较困扰的,现在不觉得只是因为都瘸习惯了而已..
1>. Model 的字段不明,这个在 Java 还真不是问题,因为 Java 会区分 field 和 method 的调用方式。该加 () 加 (). rubyist 早就习惯不加 () 的调用方式了。导致看代码过程中你无法区分是 field 还是 method. 就需要回头看 schema.rb 或者 直接瞄数据库..
2>. Controller 的 Mapping 不明,这个在 Java 上也不是问题.. 因为 Java 现在的实现方式都是 Annotation( 直接标注在方法上).. 往往在 debug 的时候经常会某个 url 出错,需要立即进入对应的 Controller 看看代码。发现你得先进 routes.rb 看看到底是哪个东西映射的。尤其在 Rails 4 之后,routes Concern 加进来,找都找不着...
很多人说:你瘸了,我卖你副拐吧.. annotate
, rake routes | grep
两副拐到手,你终于能走正步了..
出门跟邻里相亲打招呼,发现为啥就自己需要拄拐。哀叹自己遗传基因不好.. 听天由命。
突然旁边就走来一个大叔面带微笑:
!![]((http://d.pr/i/4j5X+)
潜心修炼两个时辰,你就脱拐了.. 仔细询问邻里相亲,发现他们都是这样脱拐的。..
其实书里面只写着三个单词:你将整书付之一炬,刻与村头木板石碑,退隐江湖,深藏功与名。
石碑上刻着: . . . ^^^^^^^^^^^^^^^^^^^ | # Sinatra + DataMapper | vvvvvvvvvvvvvvvvvvvvvv
string.coffee
就有 2k 行的代码。
其实是挺恐怖的... 如果我们都有 Google 的 10G 网络,那可能就没人 care 这个问题了...
#6 楼 @zacker330 这个确实是问题.. 程序的可读性会有影响。无论用什么方式解决,原生的 AR 都没有提供解决方案。
我就在静等 DataMapper 2 了..
问题是你为什么要同时开发两个 Gem,如果都是新作的,应该先在 lib 目录才对。
后抽离出去,一口吃成胖子能行么?
客户端产品其实可以通过 Google Analytics 嵌入不同的 Custom Event..
这样可以记录用户行为,针对性的改善用户体验。不然自己开发的成本还是挺高的。
另外,通过这个开源项目,randx 自身也实现了变现。
开源的盈利点总是有人会看到,总是有人来请你一起实现梦想。前提是你的产品足够好。