Skip to content

Instantly share code, notes, and snippets.

View chareice's full-sized avatar

ChengLei Shao chareice

  • GuangZhou China
View GitHub Profile
@chareice
chareice / validation.php
Created February 1, 2015 08:47
Localization Validation Message For Chineses With Laravel 5
<?php
use Symfony\Component\Yaml\Yaml;
return Yaml::parse(file_get_contents(base_path().'/resources/lang/zh_cn/validation.yml'));
@chareice
chareice / psql-with-gzip-cheatsheet.sh
Created April 13, 2020 03:36 — forked from brock/psql-with-gzip-cheatsheet.sh
Exporting and Importing Postgres Databases using gzip
# This is just a cheat sheet:
# On production
sudo -u postgres pg_dump database | gzip -9 > database.sql.gz
# On local
scp -C production:~/database.sql.gz
dropdb database && createdb database
gunzip < database.sql.gz | psql database
@chareice
chareice / golang, ubuntu go get in china.md
Created November 15, 2018 00:16 — forked from alexniver/golang, ubuntu go get in china.md
ubuntu下, 使用shadowsock和Privoxy帮助你在命令行中, 无障碍进行go get

#前言 由于大家都懂的, 国内使用go get的时候, 经常会各种失败, 如果有vpn的话, 打开vpn, 问题就解决了, 但vpn其实挺不灵活的.

相对来说shadowsock则灵活得多.

#解决方案 shadowsock + Privoxy

思路就是, 使用shadowsock建立一个本地sock5代理, 但因为go get 需要http代理, 所以需要使用privoxy把sock5代理转为http代理.

@chareice
chareice / clean.sh
Created September 22, 2018 06:08
clean up docker daily
echo "$(echo '0 3 * * * /usr/bin/docker system prune -f' ; crontab -l)" | crontab -
@chareice
chareice / mix.exs
Created September 29, 2016 15:15
Mix created mix.exs file
defmodule KV.Mixfile do
use Mix.Project
def project do
[app: :kv,
version: "0.1.0",
elixir: "~> 1.3",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps()]
@chareice
chareice / Rakefile
Created February 8, 2014 06:38
Hide Status Bar in rubymotion
app.info_plist['UIStatusBarStyle'] = 'UIStatusBarStyleBlackTranslucent'
app.info_plist["UIViewControllerBasedStatusBarAppearance"] = false
@chareice
chareice / install_ffmpeg_ubuntu.sh
Created March 24, 2016 03:00 — forked from xdamman/install_ffmpeg_ubuntu.sh
Install latest ffmpeg on ubuntu 12.04 or 14.04
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from https://gist.github.com/faleev/3435377
# Remove any existing packages:
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
# Get the dependencies (Ubuntu Server or headless users):
sudo apt-get update
@chareice
chareice / rm_mysql.md
Created March 11, 2016 13:54 — forked from vitorbritto/rm_mysql.md
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

brew remove mysql

@chareice
chareice / test.py
Created November 16, 2013 07:58
test
# -*- coding: utf-8 -*-
__all__ = ["DB", ]
import contextlib
import psycopg2
from psycopg2 import extensions
from gevent.socket import wait_read, wait_write
@chareice
chareice / appunittest.py
Created November 15, 2013 12:49
Flask单元测试
import unittest
from flask.ext.testing import TestCase
from testconfig import TestConfig
from admin import app
from admin.urls import url_routes
from init_app import create_app
from extensions import db
def assertCreate(models):