`
南京老油条
  • 浏览: 55801 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论
文章列表
有这样一个应用: 一个向外推送帖子的网站,需要记录帖子都为哪些用户浏览过。怎么设计?   设计一(很粗糙的实现) 将帖子和用户做多对多关联,关联上了就是阅读过了。 那么问题来了,当用户数达到千万级别,帖子数达到万级,那将是很可怕的数量。   设计二(一位资深人士给的做法) 为每一个帖子开辟一个8M的存储空间,按照用户的id记录用户是否阅读过,以0表示false,1表示true。当然用户的id是从1开始自增长的。   我想说这两方法都太浪费存储资源了 关键是记录用户的最后访问时间,帖子的发布时间。 只要将用户的最后登陆时间和当前时间之间发布的帖子塞进用户的未读列表即可( ...
安装 pip install elasticsearch     es_client.py # -*- coding: utf-8 -*- import random import requests from elasticsearch import Transport from elasticsearch.connection import RequestsHttpConnection from config.base_config import ES_HOSTS, ES_INDEX, ES_CONNECTION_NUM hosts = [] for host i ...
  原文  http://oldfritter.iteye.com/blog/2103337 200行代码搞定订单系统主体 概述 订单更新绝大多数是控制订单状态的改变.在此,我将订单状态抽象成点(order_status),改变订单状态的方法称为operation,operation不直接与订单相关,只与order_status相关.    当订单状态发生改变时,订单包含的操作便自然变更为新的可执行操作   样例 以下是一个电商网站的状态流转图     我是这样做模型层的 class Order < ActiveRecord::Base belongs_ ...
原文  http://oldfritter.iteye.com/blog/2102044   最近在写一个微信支付的gem. 代码 git clone https://github.com/oldfritter/wcpay.git  欢迎有兴趣的一起开发. 我之前已经制作了支付宝和银联的支付GEM,有在线项目使用. 主体代码已经完成,找一个壕朋友看看使用的反馈.(微信2W门槛)
Installation Add this line to your application's Gemfile: gem 'upop', :git => 'https://github.com/oldfritter/upop' And then execute: $ bundle install Usage
本文旨在介绍如何完成在应用Ruby开发的网站(非Rails亦可)内集成支付宝的手机网页支付功能.   1.安装GEM包:   gem 'alipay_mobile', :github => 'https://github.com/oldfritter/alipay_mobile'  2.配置     AlipayMobile.pid = 'YOUR_PID' AlipayMobile.key = 'YOUR_KEY' AlipayMobile.seller_email = 'YOUR_SELLER_EMAIL'  3.完成支付业务 options = {req_ ...
本文介绍通用的使用第三方接入的方法,可以类似做出接入其它网站(如QQ等,注:目前QQ自己做的比较乱,观望之)   应用场景例子:  网站A使用Weibo的接口,使Weibo的用户不用在网站A上注册新用户即可登陆网站A,并使用网站A的相关功能.   开发指导. 1.安装 oauth2 Gemfile gem 'oauth2', :git => 'https://github.com/oldfritter/oauth2' 申请key和secret在此就不赘述了   2.业务代码范例 require 'oauth2' @client = OAuth2::Client ...
下载   wget http://mirrors.cnnic.cn/apache/lucene/solr/4.7.2/solr-4.7.2.tgz tar -xzvf solr-4.7.2.tgz cd solr-4.7.2/example java -jar start.jar 现在已经可用了. 追求性能可以去调试各项参数(前提是你要熟悉Solr),换用自己喜欢的容器. 默认使用Jetty运行的,性能跟Tomcat不相上下   Ruby connect code require 'rubygems' require 'rsolr' # Direct ...
  Rails4 中scope推荐写法,代替原先的lambda   scope :all_by_shop, ->(store_id) {where("(receiver_id = ? AND receiver_type = 'User') OR (sender_id = ? AND sender_type = 'User')", store_id, store_id)}    
最新更新请看 https://github.com/oldfritter/upmp.git A simple upmp ruby gem, without unnecessary magic or wraper, it's directly facing how upmp api works.   Installation Add this line to your application's Gemfile: gem 'upmp', :git => 'https://github.com/oldfritter/upmp' And then execute: ...

各类型对照

Rails db2 mysql openbase Oracle :binary blob(32678) blob object blob :boolean decimal(1) tinyint(1) boolean number(10) :date date date date date :datetime timestamp datetime datetime date :decimal decimal decimal decimal decimal :float float float fl ...
制作方法比较简单 1.下载国服星际2的windows版客户端 2.下载台服或者美服等的客户端(任意一个即可) 3.将台服Mac客户端中的以下文件或文件夹拷贝至国服客户端的相应位置 StarCraft II     (app文件) StarCraft II Public Test      (app文件) StarCraft II Editor    (app文件) Support    (目录) Updates     (目录)   已经不用这么搞了
ActionController::RoutingError (No route matches [GET] "/javascripts/application.js") 的解决方法 RAILS_ENV=production bundle exec rake assets:precompile  production.rb中添加 config.serve_static_assets = true  
这里简单介绍使用 rails + mongodb 项目创建   1.安装rvm curl -L https://get.rvm.io | bash -s stable   2.安装ruby rvm install 2.0.0   3.安装rails gem install rails   4.安装mongo和mongoid gem install mongo gem install mongoid   5.生成项目 rails new blog_with_mongo --skip-active-record --skip-test-unit   6.添加m ...
创建文件 config/initializers/quiet_assets.rb   写入代码 if Rails.env.development? Rails.application.assets.logger = Logger.new('/dev/null') Rails::Rack::Logger.class_eval do def call_with_quiet_assets(env) previous_level = Rails.logger.level Rails.logger.level = Logger::ERROR if ...
Global site tag (gtag.js) - Google Analytics