Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
Hooopo
@hooopo
管理员
第 8 位会员 / 2011-10-28

[email protected]
nil
北京
160 篇帖子 / 3013 条回帖
360 关注者
0 正在关注
74 收藏
聪明的妖怪录下了唐僧的紧箍咒
打赏作者
GitHub Public Repos
  • oh-my-github-circles 47

    GitHub User Circle Generator Using GitHub Actions

  • hackernews-insight 21

    Hackernews Insight using TiDB Cloud

  • repo-track-pipeline 6

    🔄 A flexible open-source data pipeline for seamlessly syncing data from any repository to your da...

  • oh-my-github-pipeline 6

    🔄 A flexible open-source data pipeline for seamlessly syncing data from any github user to your d...

  • chatgpt-xiaoai 3

    小爱音箱集成LLM,SaaS 服务

  • repo-contributor-circles 1

    GitHub repo contributor circles generator.

  • ossinsight-x 1

    Automatically post trending repos to Twitter every day.

  • mi-service 1

    XiaoMi Cloud Service for mi.com

  • hooopo 0

  • streamlit-echarts-demo 0

    Demo for Streamlit ECharts component

More on GitHub
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • RubyMotion - Ruby 写 iOS 应用 at 2012年05月21日

    http://news.ycombinator.com/item?id=3989493

  • Ruby China 节点的主题数统计 at 2012年05月21日

    会成为第一名的

  • 想到一段很好玩的代码. 很短... 小小测验一下! at 2012年05月18日

    #13 楼 @zw963 我已经提前公布了:http://rubylution.herokuapp.com/topics/7#reply-17 哇卡卡

  • 数值有哪些友好的显示方示? at 2012年05月18日

    sprintf

  • 毕业神照 at 2012年05月17日

    怎么不穿裙子??

  • mini_magick 如何裁剪数据库里面的图片 at 2012年05月17日

    你去 iamgemagick 文档上面把 resize crop 等命令看明白了以后图片处理 60% 的问题都解决了

  • mini_magick 如何裁剪数据库里面的图片 at 2012年05月17日

    4 格缩进好难看!

  • mini_magick 如何裁剪数据库里面的图片 at 2012年05月17日

    裁剪根本就不会拉伸!压扁!

  • 为什么 ruby-china 的 erb 源码, 代码缩进乱七八糟的? at 2012年05月17日

    我一直认为 vim 的自动格式化功能很弱!虽然大部分人鄙视用 Netbeans 的,但是 Netbeans 格式化功能是非常好用~

  • 用 Django 开发项目心情有些枯燥,如果用 rails 能不能缓解 at 2012年05月17日

    #4 楼 @skandhas 哈哈哈哈

  • 5 个常见的 Rails 开发误区 at 2012年05月16日

    #7 楼 @chinacheng 脱离 Benchmark、Profiles 来扯性能问题都是耍流氓

  • GeaKit--another social coding project in China at 2012年05月16日

    #31 楼 @jinleileiking https://github.com/torvalds/linux/pull/17

  • GeaKit--another social coding project in China at 2012年05月16日

    我们都在鄙视链中,Linus 鄙视用 Github 的,用 Github 的鄙视用山寨 Github 的,用山寨 Github 的鄙视用 SVN 的.......

  • Ruby 和元编程的故事 - 第 2 回:类与模块,Ruby 的绝代双骄 at 2012年05月15日

    #25 楼 @googya 元编程 is all about self definee and scope.

  • Rails 中的线程如何写 Logger 日志 at 2012年05月15日

    不知道你为啥一定要用线程。

    system('sleep 10 && cmd > tmp/shell.log 2>&1 &')
    
  • Rails 中的线程如何写 Logger 日志 at 2012年05月15日

    这东西用 shell out 或进程通讯多好哇 线程不太好控制,特别是在 Rails 里的,受服务器模型影响

  • 想到一段很好玩的代码. 很短... 小小测验一下! at 2012年05月15日

    111111 333333 555555 ?

  • 哪个 GEM 具备语法解析的功能? at 2012年05月14日

    没找到 parser,找到了一个 generator:https://github.com/defunkt/nginx_config_generator 不过有人说这是 JSON 语法:http://helloworld.group.iteye.com/group/topic/17450?page=2 貌似 json 库解析不了,楼主可以试试

  • 有熟悉 Fiber 的吗,Fiber 应该怎样销毁? at 2012年05月14日

    楼主可以看看 rack fiber pool 的实现。

  • Ruby One-Liners at 2012年05月13日

    #5 楼 @camel 这些变量是从 Perl 那继承过来的,如果没有 Perl 语言的经验会觉得别扭。 不过作为胶水语言,ruby 可以调用 awk 和 sed,grep 等,可读性可写性比 shell 强很多,又可以利用 Ruby 自身特有的功能和丰富的 gems

  • Ruby One-Liners at 2012年05月13日

    #4 楼 @zw963 最近在看《Ruby 系统管理实践》,又学到很多 Rails 里永远接触不到的 Ruby 用法....过几天总结一下:-)

  • 短域名是如何实现的 at 2012年05月13日

    #10 楼 @camel 有的网站是为了这种考虑隐藏起来,也有很多网站没有隐藏 id 的,比如 so 和 zhihu。 我觉得这属于一个不太重要的细节,至于想防爬取,可以通过验证码等其他手段。不能因为这个增加开发的复杂度。

  • 短域名是如何实现的 at 2012年05月13日

    #6 楼 @camel 豆瓣现在还是自增 id,而且暴露在外面。 我有时候搞不懂为啥不可以暴露?是为了伪造用户数量的时候可以不被别人发现?

  • 短域名是如何实现的 at 2012年05月13日
    ruby -e "puts 123456.to_s(36)"
    2n9c
    

    Ruby 本身就可以 Base36 呢

  • [求助] rails 提交表单魔法 at 2012年05月13日

    可以看一下这个:http://ruby-china.org/topics/440

  • 如果某一个 Controller 下的动作实在太多,用什么方式可以分离呢。 at 2012年05月13日

    RESTful

  • 如何在 observer 生成 log 时取得"当前登陆用户"的信息? at 2012年05月11日

    有在 model 里取得 current_user 的 hack 方法(http://qichunren.iteye.com/blog/551968),不过我觉得不好。并且有些实现还不是线程安全的。

    我比较推荐的使用方法是下面两种:

    一般这种 observer 都是和用户相关的,比如你这个例子,用户创建了一个 project,project 一定要有 user_id,在 callback/observer 里就可以直接取这个 user_id,而不是去找 current_user,current_user 的含义是和会话相关的。

    class ProjectObserver < ActiveRecord::Observer
    def after_save(proj)
        Event.create(
          :project => self,
          :type => xxx,
          :author =>  proj.user 
        )
      end
    end
    

    如果你觉得有些时候在 project 这个表里加 user_id 会是冗余的,可以通过虚拟属性还解决,比如 Model 里:

    class Project < AR
      attr_accessor :user_id
    end
    

    Controller 里:

    Project.create :user_id => current_user.id, ...
    

    Observer 里:

    class ProjectObserver < ActiveRecord::Observer
    def after_save(proj)
        Event.create(
          :project => self,
          :type => xxx,
          :author =>  proj.user_id 
        )
      end
    end
    

    还有些时候会考虑到性能,其实是不必要的,像这样的主键查询永远也成为不了瓶颈。而且,还有 AR 的 query cache 会帮你挡一下。

  • 那种 API 设计好? at 2012年05月11日

    http://api.twitter.com/statuses/:id.format 这种最好吧?

  • 提醒了我一下 Ruby 脚本语言的本质 -_-@ at 2012年05月11日

    啊?

  • 上一页
  • 1
  • 2
  • …
  • 91
  • 92
  • 93
  • 94
  • 95
  • …
  • 108
  • 109
  • 下一页
关于 / RubyConf / Ruby 镜像 / RubyGems 镜像 / 活跃会员 / 组织 / API / 贡献者
由众多爱好者共同维护的 Ruby 中文社区,本站使用 Homeland 构建,并采用 Docker 部署。
服务器由 赞助 CDN 由 赞助
iOS 客户端 / Android 客户端 简体中文 / English