Skip to content

Instantly share code, notes, and snippets.

View t7y's full-sized avatar
🏠
Working from home

Jerry Tian t7y

🏠
Working from home
View GitHub Profile
[DEBUG] 2020-03-31 21:51:03,684 - [server.lib.arm.scheduled_rules.hotel_ratio_rules_engine]: Skipping unit:9229 date:2020-05-26 attrs because its currently booked
[DEBUG] 2020-03-31 21:51:03,684 - [server.lib.arm.scheduled_rules.hotel_ratio_rules_engine]: Skipping unit:9235 date:2020-05-15 attrs because its currently booked
[DEBUG] 2020-03-31 21:51:03,684 - [server.lib.arm.scheduled_rules.hotel_ratio_rules_engine]: Skipping unit:9235 date:2020-06-14 attrs because its currently booked
[DEBUG] 2020-03-31 21:51:03,684 - [server.lib.arm.scheduled_rules.hotel_ratio_rules_engine]: Skipping unit:9240 date:2020-06-14 attrs because its currently booked
[DEBUG] 2020-03-31 21:51:03,685 - [server.lib.arm.scheduled_rules.hotel_ratio_rules_engine]: Skipping unit:9239 date:2020-06-09 attrs because its currently booked
[DEBUG] 2020-03-31 21:51:03,685 - [server.lib.arm.scheduled_rules.hotel_ratio_rules_engine]: Skipping unit:9230 date:2020-05-19 attrs because its currently booked
[DEBUG] 2020-03-31 21:51:03,685 - [server.lib.
@t7y
t7y / hotel_ratio.py
Last active March 31, 2020 02:04
hotel ratios sonder
from server.lib.arm.scheduled_rules.hotel_ratio_rules_manager import HotelRatioRulesManager
city_id = 9
bedroom_count = "2"
building_id = "1296"
HotelRatioRulesManager.apply_price_changes_for_segment(
city_id, building_id, bedroom_count
)
session = HotelRatioRulesManager.get_session()

Deploy Rails 4 app with Dokku on DigitalOcean

Install dokku

First create a Ubuntu 13.04 x64 droplet on DigitalOcean Control Panel

Then ssh with root account, run this in termianl:

$ wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | sudo bash
@t7y
t7y / install-redis.sh
Last active December 26, 2015 14:19 — forked from dstroot/install-redis.sh
#!/bin/bash
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
###############################################
# To use:
# wget https://gist.github.com/contentdj/7164925/raw/ca153f3ad5325ba6eb59ce2db7a5125d64569200/install-redis.sh
# chmod 777 install-redis.sh
# ./install-redis.sh
###############################################
echo "*****************************************"
# config/initializers/redcarpet.rb
class ActionView::Template
class Redcarpet < Handler
include Handlers::Compilable
def compile template
::Redcarpet.new(template.source).to_html.inspect
end
end
@t7y
t7y / install-ruby-debug-ruby-1.9.3.sh
Created April 27, 2012 21:07 — forked from rmoriz/install-ruby-debug-ruby-1.9.3.sh
ruby-debug in ruby-1.9.3-p194 and rbenv
#!/bin/bash
cd /tmp
wget http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
wget http://rubyforge.org/frs/download.php/74596/ruby_core_source-0.1.5.gem
wget http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
wget http://rubyforge.org/frs/download.php/63094/ruby-debug19-0.11.6.gem
export RBENV_INCLUDE=$HOME/.rbenv/versions/1.9.3-p194/include/ruby-1.9.1/ruby-1.9.3-p194
gem install archive-tar-minitar
@t7y
t7y / postfromgooglereader.rb
Created September 12, 2011 18:52 — forked from danwoolley/postfromgooglereader.rb
Post from Google Reader to Wordpress blog
#!/usr/local/bin/ruby
# Get from your personal Google Reader public share.
# Post to your WordPress blog.
# Written by Dan Woolley on 9/8/07 for http://tzetzefly.com
# Command line: ruby postfromgooglereader.rb <post_type> <days_back>
# where <post_type> is 'draft', 'live', or 'test' (default is draft)
# and <days_back> is number of days back to get from Google Reader (default is 1)
@t7y
t7y / gist:967030
Created May 11, 2011 18:38
table partition
SET constraint_exclusion = on;
EXPLAIN (ANALYZE ON, BUFFERS ON) select * from daily_keyphrase_views_main WHERE writer_id = '585144' AND date BETWEEN '2011-01-01' AND '2011-01-31' AND partition_id = (585144 % 41);
Result (cost=0.00..16912.91 rows=220703 width=71) (actual time=857.574..4492.705 rows=218272 loops=1)
Buffers: shared read=3275
-> Append (cost=0.00..16912.91 rows=220703 width=71) (actual time=857.572..4405.989 rows=218272 loops=1)
Buffers: shared read=3275
-> Seq Scan on daily_keyphrase_views_main (cost=0.00..12.60 rows=1 width=556) (actual time=0.001..0.001 rows=0 loops=1)
Filter: ((date >= '2011-01-01'::date) AND (date <= '2011-01-31'::date) AND (writer_id = 585144) AND (partition_id = 33))
ActiveRecord::RecordNotUnique Error
PGError: ERROR: duplicate key value violates unique constraint "unq_articles" DETAIL: Key (suite101_article_id)=(114849) already exists. : INSERT INTO "articles" ("title", "created_at", "writer_id", "updated_at", "permalink", "suite101_article_id") VALUES ('Earthquake%20Preparedness%20for%20Children', '2011-03-18 21:33:40.058928', 667582, '2011-03-18 21:33:40.058928', 'http://www.suite101.com/content/earthquake-preparedness-for-children-a114849', 114849) RETURNING "id"
tm23-s00155:31555 on PAGE_VIEW at just now Retry
Arguments
"{\"permalink\":\"http://www.suite101.com/content/outdoor-living-local-garden-events-sponsored-by-proven-winners-a341537\",\"title\":\"Outdoor%20Living%20Local%20Garden%20Events%20Sponsored%20by%20Proven%20Winners\",\"suite101_article_id\":\"341537\",\"cookie_id\":\"B3C1FEF4-F263-8014-B61D523352991FF6\",\"date\":\"2011-03-17T19:03:40Z\",\"referrer_url\":\"http://www.suite101.com/content/outdoor-living-local-garden-events-sponsored-by-proven-winners-a341537\",\"writer_id\":\"612880\"}"
Exception
ActiveRecord::RecordInvalid
Error
Validation failed: Suite101 article has already been taken
/var/cache/engineyard/ruby/1.8/gems/activerecord-3.0.4/lib/active_record/validations.rb:49:in `save!'
/var/cache/engineyard/ruby/1.8/gems/activerecord-3.0.4/lib/active_record/attribute_methods/dirty.rb:30:in `save!'