Skip to content

Instantly share code, notes, and snippets.

View gokure's full-sized avatar

Gang Wu gokure

View GitHub Profile
@gokure
gokure / openresty
Last active December 31, 2021 09:17
logrotate example files, put files into /etc/logrotate.d/ directories.
/usr/local/openresty/nginx/logs/*.log {
weekly
missingok
rotate 52
compress
delaycompress
notifempty
sharedscripts
postrotate
[ -e /usr/local/openresty/nginx/logs/nginx.pid ] && kill -USR1 `cat /usr/local/openresty/nginx/nginx.pid`
@gokure
gokure / mysql-convert-charset.sh
Last active September 1, 2017 09:41 — forked from samuelpismel/mysql-convert-charset.sh
Shell script to change and convert mysql databases charset and collate.
#!/bin/bash
username='username'
password='password'
database='database'
charset='utf8mb4'
collate='utf8mb4_unicode_ci'
backup=1
@gokure
gokure / styles.less
Last active May 25, 2016 11:18
Atom' styles.less
/*
* Your Stylesheet
*
* This stylesheet is loaded when Atom starts up and is reloaded automatically
* when it is changed and saved.
*
* Add your own CSS or Less to fully customize Atom.
* If you are unfamiliar with Less, you can read more about it here:
* http://lesscss.org
*/
@gokure
gokure / git-rev-parse
Last active August 29, 2015 14:20
Git rev graph
G H I J
\ / \ /
D E F
\ | / \
\ | / |
\|/ |
B C
\ /
\ /
A
@gokure
gokure / abstract_factory.php
Last active August 29, 2015 14:09
Design patterns snippets
<?php
abstract class AbstractMobileFactory {
abstract public function createMobile();
}
class AppleFactory extends AbstractMobileFactory {
public function createMobile() {
return new AppleMobile();
}
@gokure
gokure / binary_search.php
Last active August 21, 2021 09:47
Algorithms snippets
<?php
function binary_search($array, $value) {
$upper = count($array) -1;
$lower = 0;
while ($lower <= $upper) {
$mid = floor(($lower + $upper) / 2);
if ($array[$mid] == $value) {
return $mid;
@gokure
gokure / my_configs.vim
Last active December 20, 2016 09:58
VIM config file for @amix/vimrc https://github.com/amix/vimrc
" My pathogen
try
call pathogen#infect('~/.vim/bundle/{}')
catch
endtry
syntax enable
set number
set numberwidth=5
# Custom error response of parse json
module MyApp
class ParamsParser < ::ActionDispatch::ParamsParser
def call(env)
super
rescue ::MultiJson::DecodeError
[400, {'Content-Type' => 'application/json'}, [{message: 'JSON parse error'}.to_json]]
end
end
end
@gokure
gokure / app.god
Last active November 19, 2019 07:00
Maintenance (with god) scripts of Rails (unicorn, resque/resque-scheduler)
# encoding: utf-8
# god -c config/app.god
module YourApp
module God
def self.generic_monitoring(w, options = {})
# start if process is not running
w.start_if do |start|
start.condition(:process_running) do |c|
c.interval = 10.seconds
@gokure
gokure / .gemrc
Last active July 25, 2020 14:22
dot gemrc file
---
:backtrace: falset
:benchmark: false
:bulk_threshold: 1000
:sources:
- https://gems.ruby-china.com/
- https://rubygems.org/
:update_sources: true
:verbose: true
#http_proxy: http://proxy.com