Skip to content

Instantly share code, notes, and snippets.

@yaoyi
yaoyi / citus_cheatsheet.sql
Created October 13, 2019 03:51 — forked from sfriquet/citus_cheatsheet.sql
Citus Cheatsheet
-- Set number of shard
ALTER DATABASE citus SET citus.shard_count = 64;
-- Explain across all shards
SET citus.explain_all_tasks TO true;
-- Size of all distributed tables excluding indexes but including TOAST, free space map, and visibility map
SELECT logicalrelid::text tablename, pg_size_pretty(citus_table_size(logicalrelid::text)) size FROM pg_dist_partition group by tablename;
-- Size of all distributed tables including all indexes and TOAST data
@yaoyi
yaoyi / gist:e40153cd9d3766323eb9738952ce8e07
Created January 1, 2017 17:08
解决手机页面overflow scroll滑动很卡的问题
加入代码可解决这种卡顿的问题:
-webkit-overflow-scrolling: touch;
@yaoyi
yaoyi / gist:5f9ff5f1ccad2cd3c1ab8a48bc74e2f2
Created December 31, 2016 06:45
Prevent your SSH connection from freezing
cd /Users/yourname/.ssh
# If you get ""-bash: cd: .ssh: No such file or directory"
# You need to create it
mkdir /Users/yourname/.ssh
# Set security on the folder so only you can read, write and execute
chmod 700 /Users/yourname/.ssh
# Change directory
@yaoyi
yaoyi / gist:eb578f9432e7c7626a2274c40e064010
Created December 26, 2016 13:30
rsync同步服务器数据到本地
rsync -azv -e "ssh -p 20202" user@host:/src/ dest
desc "Backup the database"
namespace :db do
task :backup do
on roles(:db) do |host|
backup_path = "#{fetch(:deploy_to)}/backups"
execute :mkdir, "-p #{backup_path}"
basename = 'database'
username, password, database, host = get_remote_database_config(fetch(:stage))
debug "#{username}, #{password}, #{database}"
# put this in config/initializers/carrierwave.rb
module CarrierWave
module MiniMagick
def quality(percentage)
manipulate! do |img|
img.quality(percentage)
img = yield(img) if block_given?
img
end
end
from datetime import datetime
from hashlib import md5
from scrapy import log
from scrapy.exceptions import DropItem
from twisted.enterprise import adbapi
class FilterWordsPipeline(object):
"""A pipeline for filtering out items which contain certain words in their
description"""
@yaoyi
yaoyi / README.md
Created February 13, 2014 14:39 — forked from nicerobot/README.md

To run this, you can try:

curl -ks https://gist.github.com/nicerobot/2697848/raw/uninstall-node.sh | bash

I haven't tested this script doing it this way but i run a lot of my Gists like this so maybe this one'll work too.

Alternatively,

curl -ksO https://gist.github.com/nicerobot/2697848/raw/uninstall-node.sh

chmod +x ./uninstall-node.sh

@yaoyi
yaoyi / Gemfile
Created February 7, 2014 14:30 — forked from zernel/Gemfile
gem 'devise'
gem 'omniauth'
gem 'omniauth-github'
gem "omniauth-twitter"
gem "omniauth-facebook"
gem "omniauth-google-oauth2"