Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
花错
@flowerwrong
会员
第 9442 位会员 / 2013-10-06

广州
47 篇帖子 / 1109 条回帖
36 关注者
35 正在关注
233 收藏
人生有如花错
未设置 GitHub 信息。
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • 如何实现一个带权限控制的相册 at 2014年08月25日

    #2 楼 @jzlikewei 把图片名字 hash 或许可以

  • 如何实现一个带权限控制的相册 at 2014年08月25日

    #2 楼 @jzlikewei 把图片名字 hash 或许可以

  • Rails 和 Sinatra 谁更适合做 APP 的后台? at 2014年08月25日

    #34 楼 @debugger 好书

  • Rails 和 Sinatra 谁更适合做 APP 的后台? at 2014年08月25日

    直接 grape 吧,如果要在上面写 api 文档就加上 sinatra(web 页面)和 SwaggerUI(api 的 ui 界面)

  • 前端招聘中,“熟悉一门后端语言” 具体是什么要求? at 2014年08月22日

    如果是你带着做,我觉得就合格了。

  • Rails 真复杂呀 at 2014年08月22日

    #8 楼 @huacnlee 我也觉得,我一直用原生态。楼主数据库就列了四个,我觉得两个重复了。还有框架就列了三个。

  • 才发现 36 氪使用 Ruby China 二次开发的呀 at 2014年08月22日

    哈哈,以前是 wordpress,很久的事了。你再去看他的论坛。

  • 一个极其好用的取色网站 at 2014年08月22日

    #27 楼 @chairy11 给你看的。

  • 一个极其好用的取色网站 at 2014年08月21日

    #6 楼 @chairy11 你的 blog 挂掉啦!!! http://topit.me/

  • 除了 Kingaxis 的云梯外,我开始搞 Catch 的秒视啦 at 2014年08月21日

    #32 楼 @kgen 搞云梯会被请喝茶吗?

  • 关于网页抓取的学习历程 at 2014年08月21日

    #8 楼 @lanyatou 模拟用户操作

  • 关于网页抓取的学习历程 at 2014年08月21日

    #6 楼 @lanyatou capybara 貌似用作测试不错,抓取还是有性能问题

  • 关于网页抓取的学习历程 at 2014年08月21日

    ruby 的相关 gem 有 curb(curl) 适合抓取 json 通信类数据,mechanize 适合抓取少 js 和 iframe 类页面,watir 貌似只能用来做测试,直接模拟浏览器,但是速度可想而知。phantomjs 据说很不错,没用过。

  • 怎么把 rails s 添加成服务,开机自启动 at 2014年08月21日

    rails s 应该就是 webrick。楼主真要这么干?还是换 thin 或者 puma 吧,或者省事点 apache+passenger

  • [已解决] HTML 自带 audio 播放器无法外加控制 at 2014年08月21日

    浏览器自带的就够啦。

  • ruby 中 url encode from GB2312 的问题 at 2014年08月20日

    #3 楼 @lonre 没,我是告诉其他人而已,u r right.

  • 请教大家怎么部署 rails 应用到生产环境 at 2014年08月20日

    nginx+passenger+mysql 的:https://ruby-china.org/topics/20216 apache+php+mysql+passenger 的:http://flowerwrong.iteye.com/blog/2105093

  • ruby 中 url encode from GB2312 的问题 at 2014年08月20日

    #1 楼 @lonre thx very much 顺便说一下

    "str".force_encoding("gbk")
    

    这样是没用的!!!

  • 使用 mechanize 模拟登陆 ruby-china 成功,但是使用 curl 失败了。 at 2014年08月19日

    补充 watir 版本

    # -*- coding: utf-8 -*-
    require 'watir-webdriver'
    b = Watir::Browser.new
    
    USER_NAME = "[email protected]"
    PASS = "xxx"
    login_url = "https://ruby-china.org/account/sign_in"
    
    
    
    b.goto login_url
    b.text_field(:name => 'user[login]').set USER_NAME
    b.text_field(:name => 'user[password]').set PASS
    
    b.button(:name => 'commit').click
    puts b.text
    
  • 使用 mechanize 模拟登陆 ruby-china 成功,但是使用 curl 失败了。 at 2014年08月19日

    #3 楼 @saiga thx

  • 使用 mechanize 模拟登陆 ruby-china 成功,但是使用 curl 失败了。 at 2014年08月19日

    #1 楼 @saiga 我改了下,先 get 取得 token,然后 post,可是还是不行

    require 'curb'
    require 'nokogiri'
    
    USER_NAME = "[email protected]"
    PASS = "xxx"
    login_url = "https://ruby-china.org/account/sign_in"
    
    c = Curl::Easy.new
    c.url = login_url
    c.http_get
    
    doc = Nokogiri::HTML(c.body_str)
    csrf_token = doc.xpath("//meta[@name='csrf-token']/@content")[0].value.strip
    c.url = login_url
    c.enable_cookies = true
    c.cookiejar = "cookies.txt"
    
    user = {
      "user\[login\]" => USER_NAME,
      "user\[password\]" => PASS,
      "authenticity_token" => csrf_token,
      "user\[remember_me\]" => 0,
      "utf8" => "✓",
      "commit" => "登陆"
    }
    c.http_post(c.url,user)
    
    puts csrf_token
    puts "---" * 20
    puts c.header_str
    

    打印结果

    flowerwrong@flowerwrong:~/dev/ruby/mechanize$ ruby ruby_china.rb 
    2O85a3ZBPvdTyo3XQNvvvVlg57VLQ/+vhm3ktyIXXbE=
    ------------------------------------------------------------
    HTTP/1.1 200 OK
    Server: nginx/1.6.0
    Date: Tue, 19 Aug 2014 10:09:45 GMT
    Content-Type: text/html; charset=utf-8
    Transfer-Encoding: chunked
    Connection: keep-alive
    Strict-Transport-Security: max-age=31536000
    X-Frame-Options: SAMEORIGIN
    X-XSS-Protection: 1; mode=block
    X-Content-Type-Options: nosniff
    ETag: "c889b4d41d8ddd454f2d022cdc8ef457"
    Cache-Control: max-age=0, private, must-revalidate
    X-Request-Id: ffce7524-a903-4844-943e-0b54b872ccfc
    X-Runtime: 0.042324
    
    
  • Rails 4 指定第二个数据库,如何执行 migration? at 2014年08月14日

    RAILS_ENV=production rake db:migrate 默认是 test+development

  • [求助] Redcarpet 把 Markdown 转换为 HTML 后换行问题 at 2014年08月13日

    js 或者 ruby 的可以操作 html 的 gem,遍历一次,替换吧。

  • 求黑 JS 的一张图 at 2014年08月12日

    #5 楼 @blacktulip 哈哈

  • 基于 xmpp 的 Rails 项目该如何构建? at 2014年08月12日

    #11 楼 @Guest 你用过吗?这个架构情况怎样?

  • 其实元编程很烦人 at 2014年08月12日

    @billy 印象最深的就是 activerecord,不用声明对象属性。还没写过,楼主主要用在那些地方?

  • [已解决] 有没有关于项目如何使用 markdown 的简明教程? at 2014年08月11日

    #16 楼 @chairy11 嗯,使用缓存更好。

  • [已解决] 有没有关于项目如何使用 markdown 的简明教程? at 2014年08月11日

    #14 楼 @chairy11 每次解析 md 会耗费资源

  • 为什么好多工具是用 ruby 写的?而不是用 python,perl? at 2014年08月11日

    我怎么觉得 ruby 东西太少呢?

  • [已解决] 有没有关于项目如何使用 markdown 的简明教程? at 2014年08月11日

    #10 楼 @chairy11 update 里面的我没写,但是除了 content 字段保存 html 内容外,还有一个 markdown 字段保存 markdown 原格式。所以

    def update
      @article = Article.find(params[:id])
      markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, tables: true, fenced_code_blocks: true)
      html_content = markdown.render(article_params[:markdown])
      @article.content = html_content
      @article.markdown = article_params[:markdown]
      respond_to do |format|
        if @article.save
          format.html { redirect_to @article, notice: 'Article was successfully updated.' }
          format.json { render :show, status: :ok, location: @article }
        else
          format.html { render :edit }
          format.json { render json: @article.errors, status: :unprocessable_entity }
        end
      end
    end
    

    就 ok 了。喔,对了,markdown 实例可以用单例模式。这里就省了。

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