Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
Hooopo
@hooopo
Admin
NO. 8 / 2011-10-28

[email protected]
nil
北京
160 Topics / 3013 Replies
360 Followers
0 Following
74 Favorites
聪明的妖怪录下了唐僧的紧箍咒
Reward
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
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • 我的屋子里有一只蝙蝠,不知道它冬天吃什么,会不会被饿死。 at December 16, 2012

    #6 楼 @luikore 冬天没有虫子了 看来得给它买苹果去..

  • 我的屋子里有一只蝙蝠,不知道它冬天吃什么,会不会被饿死。 at December 16, 2012

    它潜伏了很久了 昨天才被我发现

  • 我的屋子里有一只蝙蝠,不知道它冬天吃什么,会不会被饿死。 at December 16, 2012

    #1 楼 @fresh_fish X,被你这么一说好害怕呢

  • 如何在网页上实现对.doc (x),.xls (x),.ppt (x) 格式文件的浏览 at December 16, 2012

    #43 楼 @bhuztez 这个东西自己用不到啊

  • Javascript 跨子域通讯 at December 16, 2012

    #13 楼 @doitian 最主要的是 IE10 才正式支持 CORS

  • [Rails Girls Beijing] 总结帖 [74 个 RailsCasts Pro 三个月免费使用福利已到,近期发放] at December 16, 2012

    #16 楼 @hellojane96 链接呢

  • Run Ruby2.0 App On Heroku at December 16, 2012

    #17 楼 @bruceyue 本地可以不预编译,heroku 强制与编译了

  • Run Ruby2.0 App On Heroku at December 16, 2012

    #15 楼 @bruceyue development 环境的 asset 相关配置和 production 环境到配置不一样呀

  • Run Ruby2.0 App On Heroku at December 16, 2012

    #12 楼 @bruceyue rails guide 里的 asset pipline 部分提到了

  • Run Ruby2.0 App On Heroku at December 16, 2012

    #10 楼 @bruceyue 文档

  • Run Ruby2.0 App On Heroku at December 16, 2012

    #8 楼 @bruceyue 部署时也可以不合并啊 不是用 Heroku 么?

  • Javascript 跨子域通讯 at December 16, 2012

    #11 楼 @bhuztez

    5. No authentication or cookies will be sent with the request
    
    In order to prevent misuse of the user’s ambient authority (e.g. cookies, HTTP credentials, client certificates, etc), the request will be stripped of cookies and credentials and will ignore any authentication challenges or Set-Cookie directives in the HTTP response. XDomainRequests will not be sent on previously-authenticated connections, because some Windows authentication protocols  (e.g. NTLM/Kerberos) are per-connection-based rather than per-request-based.
    
    Sites that wish to perform authentication of the user for cross-origin requests can use explicit methods (e.g. tokens in the POST body or URL) to pass this authentication information without risking the user’s ambient authority.
    

    这一点就不太适合吧 ---update-- 没看明白,这东西是在认证的那个请求不发送 cookie 还是所有请求都不能发送?

    http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx

  • Javascript 跨子域通讯 at December 16, 2012

    #5 楼 @bhuztez #9 楼 @knwang http://blogs.msdn.com/b/ie/archive/2012/02/09/cors-for-xhr-in-ie10.aspx 这个是 IE10 才有的。。

  • Javascript 跨子域通讯 at December 16, 2012

    #7 楼 @knwang 谢谢推荐。

  • Run Ruby2.0 App On Heroku at December 16, 2012

    #6 楼 @lionzixuanyuan 好看吧

  • Javascript 跨子域通讯 at December 16, 2012

    #5 楼 @bhuztez 那还不错呢。github 这么用的。他们不支持 ie67

  • Javascript 跨子域通讯 at December 16, 2012

    #1 楼 @luikore 即使在 chrome 下,async 属性和普通异步请求也有差异。我前些天测试发现即使加 async 属性的 js 资源还会堵塞 onload 事件

  • Javascript 跨子域通讯 at December 16, 2012

    #2 楼 @knwang 这个用起来更复杂了吧 有兼容性限制?

  • 从 API 获取字符串类型的时间,然后保存到数据库! at December 16, 2012

    先打印 str_got_at.encoding 然后打印 str_got_at.bytes.to_a.inspect 然后用 DateTime.parse(Iconv.iconv("UTF-8", "GBK", str_got_at))

  • 从 API 获取字符串类型的时间,然后保存到数据库! at December 16, 2012

    #22 楼 @stephen 。。。。。。你加上试试 看日志和异常

  • Run Ruby2.0 App On Heroku at December 16, 2012

    #4 楼 @bruceyue 那你本地怎么没有 override 呢 heroku 环境可以设置成本地一样,慢慢调吧

  • 从 API 获取字符串类型的时间,然后保存到数据库! at December 16, 2012

    中间少个空格吧 应该是2012-12-14 15:05:52

  • 从 API 获取字符串类型的时间,然后保存到数据库! at December 16, 2012

    好吧,这样!

    class StockspiderWorker
      include Sidekiq::Worker
    
      def perform
        Stock.all.each do |stock|
          @s = Net::HTTP.get(URI.parse("http://hq.sinajs.cn/list=" + stock[:market] + stock[:code]))
          @s = @s[@s.index("\"")+1, @s.rindex("\"")-1]
          @records = @s.split(",")
          str_got_at = "#{@records[30]}#{@records[31]}"
          Rails.logger.info(str_got_at)
          Rails.logger.info "*" * 100
          got_at = DateTime.parse(str_got_at)
    
          stock.update_attributes(:name => Iconv.iconv("UTF-8", "GBK", @records[0]).first.to_s, 
            :volume => @records[8], :obv => @records[9], 
            :op => @records[1], :ycp => @records[2], 
            :cp => @records[3], :tp => @records[4], 
            :lp => @records[5], 
            :got_at => got_at)
        end
      end
    end
    
  • 如何在网页上实现对.doc (x),.xls (x),.ppt (x) 格式文件的浏览 at December 15, 2012

    #34 楼 @bhuztez 找到 speaker deck 用的那个 gem 了:https://github.com/jonmagic/grim 可以从 pdf 获取文字和抽取成图片。

  • 从 API 获取字符串类型的时间,然后保存到数据库! at December 15, 2012
    class StockspiderWorker
      include Sidekiq::Worker
    
      def perform
        Stock.all.each do |stock|
          @s = Net::HTTP.get(URI.parse("http://hq.sinajs.cn/list=" + stock[:market] + stock[:code]))
          @s = @s[@s.index("\"")+1, @s.rindex("\"")-1]
          @records = @s.split(",")
          got_at = DateTime.parse("#{@records[30]}#{@records[31]}")
          Rails.logger.info(got_at)
          Rails.logger.info "*" * 100
          stock.update_attributes(:name => Iconv.iconv("UTF-8", "GBK", @records[0]).first.to_s, 
            :volume => @records[8], :obv => @records[9], 
            :op => @records[1], :ycp => @records[2], 
            :cp => @records[3], :tp => @records[4], 
            :lp => @records[5], 
            :got_at => got_at)
        end
      end
    end
    

    这样试试,看看日志输出

  • 从 API 获取字符串类型的时间,然后保存到数据库! at December 15, 2012

    你 worker 里到代码是怎么写的? /Users/stephen/Gupiao/app/workers/stockspider_worker.rb:17 这里出错那个方法

  • 如何在网页上实现对.doc (x),.xls (x),.ppt (x) 格式文件的浏览 at December 15, 2012

    #34 楼 @bhuztez 不记得了

  • 从 API 获取字符串类型的时间,然后保存到数据库! at December 15, 2012
    1.9.3p327 :010 > DateTime.parse(" ")
    ArgumentError: invalid date
        from (irb):10:in `parse'
        from (irb):10
        from /home/hooopo/.rvm/rubies/ruby-1.9.3-p327/bin/irb:16:in `<main>'
    1.9.3p327 :011 > Time.parse " "
    ArgumentError: no time information in " "
        from /home/hooopo/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/time.rb:267:in `parse'
        from (irb):11
        from /home/hooopo/.rvm/rubies/ruby-1.9.3-p327/bin/irb:16:in `<main>'
    1.9.3p327 :012 > 
    
    

    根据你的错误信息,你这两个错误都是因为传的是空字符串导致的。

  • 如何在网页上实现对.doc (x),.xls (x),.ppt (x) 格式文件的浏览 at December 15, 2012

    #31 楼 @bhuztez 好多这种转换的项目都是中国人搞得。。

  • 从 API 获取字符串类型的时间,然后保存到数据库! at December 15, 2012

    直接用Time.parse

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