Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
@gihnius
Member
NO. 6061 / 2013-03-10

广州
31 Topics / 335 Replies
5 Followers
0 Following
52 Favorites
GitHub Public Repos
  • jquery.qeditor 35

    This is a simple WYSIWYG editor with jQuery.

  • http-pinger 20

    A simple tool to check website status and notify via email.

  • cl-common-blog 18

    a blog engine written in common lisp

  • gomemoize 11

    memoization function in Go

  • hunchentoot-secure-cookie 9

    encodes and decodes authenticated and optionally encrypted cookie values.

  • freebsd-wifi 7

  • ht-routes 7

    route mapping and dispatching URL's for Hunchentoot in Common Lisp.

  • gosanitize 6

    Gosanitize is a whitelist-based HTML sanitizer in Go language. Given a list of acceptable element...

  • rdb-backup 5

    redis rdb backup

  • redis_online_counter 5

    Counting online users with Redis and Go.

More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • Swift 开源了 at December 05, 2015

    crystal 比 swift 快很多

  • 之前一直想学 Go 语言,有没有像 Ruby China 这样的 Go 语言社区? at December 04, 2015

    把 Go 当作不那么蛋疼的 C 来用还是不错的,有 C 基础一天入门。

  • Ruby 将引入 ".?" Safe navigation operator at October 23, 2015

    #6 楼 @nong 封装到一个方法里

  • Ruby 将引入 ".?" Safe navigation operator at October 23, 2015

    习惯了这个

    [:profile, :thumbnails, :large].reduce(u, :try)
    
  • 大家觉得 AngularJS 好吗? at October 09, 2015

    我觉得不好

  • 如何将一维数组转换成哈希 at August 27, 2015
    arr = [1, 2, 3, 4]
    hash = Hash[*arr]
    hash  #=> {1=>2, 3=>4}
    
  • 动态生成 Class at July 20, 2015

    #2 楼 @yan32768 条条大路通罗马 eval 字符串很没意思的

  • 帮忙看一下代码哪里有问题 at July 18, 2015

    #3 楼 @lrbnew 你一直把同一个 nat 的值放进数组,

    def split_dest_ip(nat) l = [] ips = nat["d_ip"].split("|")[1..-1] ips.each do |ip| nat.delete("d_ip")

    nat["d_ip"] = ip
    l << nat
    

    binding.pry end return l end 你可以通过 object_id 查看:

    p nat
    l = split_dest_ip nat
    l[0].object_id
    l[1].object_id
    l[2].object_id
    p nat
    

    你可以改为这样试试:

    def split_dest_ip(nat)
      l = []
      ips = nat["d_ip"].split("|")[1..-1]
      ips.each do |ip|
        nat.delete("d_ip")
        nat["d_ip"] = ip
        l << nat.dup
        binding.pry
      end
      return l
    end
    
  • 动态生成 Class at July 18, 2015
    1. 应该在模块定义一个方法就可以了吧?
    2. 基于 class Entity 定义新 class ruby def variant_entity(name) return if define?(name.classify.constantize) == "constant" klass = Class.new Entity do def changes end ... end Object.const_set name.classify, klass end

    仅供参考

  • 帮忙看一下代码哪里有问题 at July 18, 2015
    def split_dest_ip(nat)
      ips = nat['d_ip'].split('|').reject(&:empty?)
      ips.map{ |ip| new_nat = nat.dup; new_nat['d_ip'] = ip; new_nat }
    end
    

    未测!

  • [ 已解决 ] Rails 自动加载, 文件变动不起作用 at July 10, 2015
    Dir[File.join(Rails.root, "config/ruby-china.yml"] #用完整路径或者当前目录下的相对路径
    

    config/initializers 目录下没有 config/ruby-china.yml

  • 重要内容放七牛可以放心吗 at July 09, 2015

    加密后上传,条件允许的话,存放多个位置:七牛,S3,Dropbox, GoogleDrive

  • 希望在 ROR 实现单表内全字段搜索 at July 09, 2015

    好奇怪的需求,不过 rails 应该没有内建的方法吧,要自己动手。 是这样理解么:

    全字段 = Information.attribute_names # 可以 reject 一下
    条件 = 全字段.collect{|f| "#{Information.table_name}.#{f} LIKE ?"}.join(' OR ')
    查询 = "%#{params[:name]}%"
    值 = [查询] * 全字段.length
    结果 = Information.where(条件, *值)
    
    
  • Rails 4 怎样 create without call back? at July 08, 2015
    def get_share
      if not 所谓的有的时候
        ...
        ...
      end
    end
    

    😄

  • 关于订单失效 at June 17, 2015

    r#3 楼 @hxh1246996371 读取的时候判断吧,如果判断的逻辑很复杂,就加个‘是否有效’的属性保存下来。

  • 做一个任务分配功能,可以拖动左侧的数据到右侧,按 shift 可多选,请问有人知道网上可推荐的插件或者类似的吗? at June 15, 2015

    https://jqueryui.com/sortable/#empty-lists 这种么?

  • 如何优雅地把 Hash 参数传递给 JavaScript at June 15, 2015

    偏好:render json: obj 不过多个请求。

  • [已解决] 同时使用 tab 和 lazy_high_chart,怎么使图表宽度为 100%? at June 02, 2015

    在处理响应式页面的时候我用的是: $(this).highcharts().reflow() $(this)是 highchart 的 DOM obj bs nav-tab 不是有事件调用吗?绑定 tab 的 click/shown 然后调用 reflow() 有没有试过?

  • Ruby 中通过 AES-128-CBC 加密后密码和 Java 中通过 AES/CBC/PKCS5Padding 加密的密码不一致? at May 29, 2015

    少了步骤了吧:

    data = "45b00417-f7ca-4f53-bced-c1743d85604c"
    cipher = OpenSSL::Cipher::AES.new(128, :CBC)
    cipher.encrypt
    key = "quck7295abvdefgh"
    iv = "abcdefgh3762quck"
    
    cipher.key = GENERATE_KEY_FROM(key) 
    # 其实这里的 key 就是所谓的 password, 根据具体的算法生成 cipher key,比如 pbkdf2
    # cipher key 的长度是固定的 AES-CBC-128 的 key 是 16 位, AES-CBC-256 的 key 是 32 位
    
    cipher.iv = IV # 这里可以自定义,也可以用 cipher.random_iv
    

    encrypted = cipher.update(data) + cipher.final

  • Ruby char ASCII 相互转换 at May 24, 2015

    有个简单通用的方法:

    "中文abc".codepoints
    => [20013, 25991, 97, 98, 99]
    

    倒过来:

     "中文abc".codepoints.map{|x| x.chr('UTF-8') }.join
    => "中文abc"
    
  • 带投票功能的 ruby-china,不是 up/down 那种投票。 at May 20, 2015

    #4 楼 @geekontheway 嗯,之前是为人家做的产品论坛,通过投票更能了解产品的各种 x

  • 带投票功能的 ruby-china,不是 up/down 那种投票。 at May 20, 2015

    #1 楼 @lgn21st 发了

  • 新手请教下,大家使用过 ruby expect 么? at May 06, 2015

    google 一大堆 example, 这个没办法给例子,只能根据你命令交互慢慢 debug 出来。 不过使用系统的 expect 命令应该比较简单,一般系统都自带这个命令,vps(精简版系统一般没有)。

    https://github.com/abates/ruby_expect http://www.admin-magazine.com/Articles/Automating-with-Expect-Scripts

  • 写起 Python 来各种不习惯…… at May 06, 2015

    楼主,

    print string 不行,非得 print(string)

    python 这个有它的好处,不知道你是否踩过 ruby 的这个坑:

    def m(a, b)
      p a,b
    end
    
    m 1, 2
    m(1, 2)
    m (1, 2)
    
  • Ruby C extension 中怎么把 C wchar 类型和 ruby string 互相转换? at May 04, 2015

    #2 楼 @luikore 谢谢。 我是指 wchar.h 里面定义的 wchar_t。

  • Visual Studio Code for Mac, Linux 来了 at April 30, 2015

    微软的 C# 还是不错,竟然要支持 Mac/Linux/FreeBSD,这是在出大招。

  • 现在可以关注人了 at April 22, 2015

    #6 楼 @huacnlee 应该加个显示关注的人的帖子列表在首页,像 twitter.

  • 旧爱 Bootstrap,新欢 Materialize at April 22, 2015

    Mark. 阴影不好看,喜欢 form/input 一条 bottom line style.

  • Prev
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • …
  • 10
  • 11
  • Next
关于 / RubyConf / Ruby 镜像 / RubyGems 镜像 / 活跃会员 / 组织 / API / 贡献者
由众多爱好者共同维护的 Ruby 中文社区,本站使用 Homeland 构建,并采用 Docker 部署。
服务器由 赞助 CDN 由 赞助
iOS 客户端 / Android 客户端 简体中文 / English