Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
f = File.open("words.txt")
f1 = File.new("output.xml", "wb")
f2 = File.new("error.txt", "wb")
f1.write "<wordbook>\r\n"
while line = f.gets
day | amount
---------------------+--------
2013-11-02 00:00:00 | 7
2013-11-03 00:00:00 | 4
2013-11-04 00:00:00 | 5
2013-11-05 00:00:00 | 33
2013-11-06 00:00:00 | 15
2013-11-07 00:00:00 | 15
2013-11-08 00:00:00 | 17
2013-11-09 00:00:00 | 15
CREATE OR REPLACE FUNCTION complex_retension_sfunc(result integer[], retension_record bit varying) RETURNS integer[] AS $$
DECLARE
bit_length integer := 0;
BEGIN
bit_length := BIT_LENGTH(retension_record);
-- 初始化 result
IF result IS NULL THEN
result := '{}';
FOR i IN 1..bit_length LOOP
@justqyx
justqyx / pg_timezone_names.txt
Created April 24, 2014 08:05
select * from pg_timezone_names;
name | abbrev | utc_offset | is_dst
----------------------------------+--------+------------+--------
Africa/Abidjan | GMT | 00:00:00 | f
Africa/Accra | GMT | 00:00:00 | f
Africa/Addis_Ababa | EAT | 03:00:00 | f
Africa/Algiers | CET | 01:00:00 | f
Africa/Asmara | EAT | 03:00:00 | f
Africa/Asmera | EAT | 03:00:00 | f
Africa/Bamako | GMT | 00:00:00 | f
Africa/Bangui | WAT | 01:00:00 | f
@justqyx
justqyx / deploy.rb
Created April 24, 2014 03:58 — forked from kirs/deploy.rb
# Capistrano configuration
#
# require 'new_relic/recipes' - Newrelic notification about deployment
# require 'capistrano/ext/multistage' - We use 2 deployment environment: staging and production.
# set :deploy_via, :remote_cache - fetch only latest changes during deployment
# set :normalize_asset_timestamps - no need to touch (date modification) every assets
# "deploy:web:disable" - traditional maintenance page (during DB migrations deployment)
# task :restart - Unicorn with preload_app should be reloaded by USR2+QUIT signals, not HUP
@justqyx
justqyx / Gemfile
Last active August 29, 2015 13:57
Upyun Integration
# Image
gem "carrierwave"
# delay load it when necessory or the rest-client should cause thread-unsafe for Net::HTTP
gem "carrierwave-upyun", github: "kaichen/carrierwave-upyun"
gem "mini_magick"
gem 'rails_config'
gem "faraday"
gem 'simple_form'
-- PostgreSQL 9.2 beta (for the new JSON datatype)
-- You can actually use an earlier version and a TEXT type too
-- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8
-- Inspired by
-- http://people.planetpostgresql.org/andrew/index.php?/archives/249-Using-PLV8-to-index-JSON.html
-- http://ssql-pgaustin.herokuapp.com/#1
-- JSON Types need to be mapped into corresponding PG types
--
@justqyx
justqyx / solr_cap.md
Last active December 22, 2016 03:44 — forked from doitian/solr_cap.rb

这是从其他地方 fork 过来的部署脚本(deploy.rb 部分代码)

namespace :deploy do
  task :setup_solr_data_dir do
    run "mkdir -p #{shared_path}/solr/data"
  end
end

namespace :solr do
@justqyx
justqyx / common.js
Created September 23, 2013 06:13
值得学习的 JS
var _hmt = _hmt || [];
$.ajaxSetup({
global: false,
type: 'POST',
dataType: 'json'
});
(function($) {
$.extend({
mask: {
isEmail: (text)->
/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.test text