Skip to content

Instantly share code, notes, and snippets.

View WhiteCrow's full-sized avatar

Sihao Liu WhiteCrow

View GitHub Profile
@WhiteCrow
WhiteCrow / zabbix3_pgsql_install_1604_xenial.sh
Last active July 5, 2018 07:46 — forked from vazhnov/zabbix3_pgsql_install_1604_xenial.sh
Quick install Zabbix 3.0 in Ubuntu 16.04 xenial with PostgreSQL
# License: CC0 1.0 or newer
# https://creativecommons.org/publicdomain/zero/1.0/
# You can download this script here: https://gist.github.com/vazhnov/fcb487e6ea432fec056793ef710b5a28
wget "http://repo.zabbix.com/zabbix/3.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.0-1+xenial_all.deb"
sudo dpkg -i zabbix-release_3.0-1+xenial_all.deb
sudo apt-get update
sudo apt-get install zabbix-server-pgsql zabbix-frontend-php libapache2-mod-php php-bcmath php-mbstring php7.0-xml php-pgsql
# Zabbix can't work without password (with ident), so you need to create user with password:
@WhiteCrow
WhiteCrow / rails-jsonb-queries
Created May 24, 2018 02:20 — forked from mankind/rails-jsonb-queries
Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@WhiteCrow
WhiteCrow / README.md
Created December 7, 2017 02:29 — forked from shenqihui/README.md
fab 部署脚本

部署脚本


这是我常用的 fab 部署脚本的改写通用版本。

可能对大型项目没起作用,但是对于小项目,作用还是很大,所以发出来写个文章分享下。


user=...
pass=...
host=localhost # or remote if necessary
database=...
mysqldump -u${user} -p${pass} -h ${host} --add-drop-table --no-data ${database} | grep ^DROP | mysql -u${user} -p${pass} -h ${host} ${database}
@WhiteCrow
WhiteCrow / mysqldump.sh
Created May 23, 2017 08:31 — forked from jbonney/mysqldump.sh
MySQL dump to export data only (no DB schema nor table instructions). Particularly useful when exporting a Rails DB to re-import it afterwards in a DB that has been created through `rake db:drop db:create db:migrate`.
mysqldump --user="username" --password="password" --skip-triggers --compact --no-create-info --ignore-table="database_name.schema_migrations" --ignore-table="database_name.table_populated_through_migration" "database_name" > "dump.sql"
@WhiteCrow
WhiteCrow / digital_ocean_setup.md
Created August 7, 2016 15:27 — forked from ChuckJHardy/digital_ocean_setup.md
DigitalOcean Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3 Setup Instructions
@WhiteCrow
WhiteCrow / gollum.config.ru
Created May 27, 2016 07:55 — forked from scollett/gollum.config.ru
A lightweight author identification for Gollum wiki (with some preferences). Use config.ru to run Gollum as a rack application. Basic HTTP Authentication is commented out.
#!/usr/bin/env ruby
require 'rubygems'
require 'gollum/app'
gollum_path = File.expand_path(File.join(File.dirname(__FILE__), 'database.git')) # CHANGE THIS TO POINT TO YOUR OWN WIKI REPO
Precious::App.set(:gollum_path, gollum_path)
Precious::App.set(:default_markup, :markdown) # set your favorite markup language
Precious::App.set(:wiki_options, {:live_preview => false, :universal_toc => false, :user_icons => 'gravatar'})
module Precious
class App < Sinatra::Base
# Creates a simple authentication layer
module CarrierWave
module MiniMagick
def toaster_filter
manipulate! do |img|
img.modulate '150,80,100'
img.gamma 1.1
img.contrast
img.contrast
img.contrast
img.contrast
@WhiteCrow
WhiteCrow / show.html.erb
Created March 7, 2012 09:46 — forked from michaelward82/show.html.erb
Dynamic page parts in RefineryCMS
<% left_col_content = @page.content_for(:left_column) %>
<% content_content = @page.content_for(:content) %>
<% right_col_content = @page.content_for(:right_column) %>
<% if (!left_col_content && !!content_content && !right_col_content) -%>
<%= render :partial => 'content', :object => @page,
:locals => { :css => "grid_12 alpha omega" } %>
<% end -%>
<% if (!!left_col_content && !!content_content && !right_col_content) -%>
<%= render :partial => 'leftcol', :object => @page,