Skip to content

Instantly share code, notes, and snippets.

View bobzhen's full-sized avatar

Hongbo Zhen bobzhen

  • Alibaba
  • Shenzhen, China
View GitHub Profile
@bobzhen
bobzhen / postgres-brew.md
Created April 14, 2020 19:48 — forked from ibraheem4/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@bobzhen
bobzhen / .dockerignore
Created April 9, 2020 16:10 — forked from davidderus/.dockerignore
Docker + Rails + Puma + Postgres + Nginx
.git
.gitignore
/doc
.yardoc
coverage
jsdoc
/tmp
/log
Dockerfile
Dockerfile.prod
@bobzhen
bobzhen / app.DockerFile
Created April 8, 2020 18:12 — forked from satendra02/app.DockerFile
docker+rails+puma+nginx+postgres (Production ready)
FROM ruby:2.3.1
# Install dependencies
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
# Set an environment variable where the Rails app is installed to inside of Docker image:
ENV RAILS_ROOT /var/www/app_name
RUN mkdir -p $RAILS_ROOT
# Set working directory, where the commands will be ran:
const xor = array => {
if (Array.from(array).every(a => !!a)) return false
const someEmpty = Array.from(array).some(a => !a)
const somePresent = Array.from(array).some(a => !!a)
return someEmpty && somePresent
}
@bobzhen
bobzhen / hugo_seo.html
Created February 1, 2020 09:11 — forked from jeremyjaymes/hugo_seo.html
Hugo SEO Markup
<meta name="description" content="{{ if .IsHome }}{{ .Site.Params.description }}{{ else }}{{ .Description }}{{ end }}"/>
<meta name="robots" content="noodp"/>
<link rel="canonical" href="{{ .Permalink }}" />
<!-- Twitter Card -->
<meta name="twitter:card" content="summary" />
<meta name="twitter:description" content="{{ if .IsHome }}{{ .Site.Params.description }}{{ else }}{{ .Description }}{{ end }}" />
<meta name="twitter:title" content="{{ .Title }}{{ if .IsHome }} - {{ .Site.Params.Tagline }}{{ else }} - {{ .Site.Title }}{{ end }}" />
<meta name="twitter:site" content="{{ .Site.Params.twitter }}" />
<meta name="twitter:creator" content="{{ .Site.Params.twitter }}" />
@bobzhen
bobzhen / git-pushing-multiple.rst
Created December 11, 2019 06:38 — forked from rvl/git-pushing-multiple.rst
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just

@bobzhen
bobzhen / clear-sidekiq-jobs.sh
Created December 7, 2019 05:55 — forked from wbotelhos/clear-sidekiq-jobs.sh
Clear Sidekiq Jobs
require 'sidekiq/api'
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
@bobzhen
bobzhen / postgres-dump-restore.markdown
Created December 1, 2019 15:57 — forked from jeremykendall/postgres-dump-restore.markdown
PostgreSQL: dump and restore (to db with different name and roles even)

Postgres Export and Import

Export

pg_dump -U [superuser] -Fc [dbname] > db.dump

Import

@bobzhen
bobzhen / MB puma + Nginx settings
Created October 28, 2019 15:24 — forked from Epigene/MB puma + Nginx settings
MB puma + Nginx settings
# /config/puma.rb
app = "manabalss" # App-specific
root = "/home/deployer/apps/#{app}"
workers 5
threads 1, 1 # relying on many workers for thread-unsafe apps
rackup DefaultRackup
port 11592
@bobzhen
bobzhen / gist:f1794c51bdb42e1475938c0dbaf328fa
Created September 15, 2019 02:43 — forked from alex-zige/gist:5795358
Rails Rspec API Testing Notes

Rails Rspec APIs Testing Notes

Folders Structure

  spec
  |--- apis #do not put into controllers folder. 
        |--- your_api_test_spec.rb  
  |--- controllers
  |--- models
  |--- factories
 |--- views