Skip to content

Instantly share code, notes, and snippets.

@baysao
baysao / git-clearHistory
Created November 11, 2019 03:00 — forked from stephenhardy/git-clearHistory
Steps to clear out the history of a git/github repository
-- Remove the history from
rm -rf .git
-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"
-- push to the github remote repos ensuring you overwrite history
git remote add origin git@github.com:<YOUR ACCOUNT>/<YOUR REPOS>.git

Keybase proof

I hereby claim:

  • I am baysao on github.
  • I am baysao (https://keybase.io/baysao) on keybase.
  • I have a public key whose fingerprint is 3EEB 31AE B377 041D E5A1 F3F1 A587 8683 5EC4 2291

To claim this, I am signing this object:

@baysao
baysao / log cm
Created July 5, 2017 04:17
log cm
[05/Jul/2017 04:05:40] ERROR [django.request:256] Internal Server Error: /backend/cm/page/trang-chu/
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 132, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/django/views/generic/base.py", line 71, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/rest_framework/views.py", line 477, in dispatch
response = self.handle_exception(exc)
@baysao
baysao / u-docker.sh
Created May 8, 2016 08:31 — forked from ephrin/u-docker.sh
docker ubuntu
[ -e /usr/lib/apt/methods/https ] || {
apt-get update
apt-get install -y apt-transport-https
}
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
sh -c "echo deb https://get.docker.com/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
apt-get update
apt-get install -y --force-yes apparmor lxc-docker
@baysao
baysao / scribe-centos
Created May 4, 2016 07:41
scribe installation script on CentOS
#!/bin/bash
echo '=================================================='
echo '===============Install necessary tools==============='
echo '=================================================='
sudo yum update
sudo yum install git make flex bison libtool automake openssl-devel libevent libevent-devel python-devel gcc-c++ byacc java-1.7.0-openjdk ant
echo '=================================================='
@baysao
baysao / Secure Sessions Howto
Created April 14, 2016 13:51 — forked from nikmartin/A: Secure Sessions Howto
Secure sessions with Node.js, Connect, and Nginx as an SSL Proxy
Secure sessions are easy, but it's not very well documented, so I'm changing that.
Here's a recipe for secure sessions in Node.js when NginX is used as an SSL proxy:
The desired configuration for using NginX as an SSL proxy is to offload SSL processing
and to put a hardened web server in front of your Node.js application, like:
[NODE.JS APP] <- HTTP -> [NginX] <- HTTPS -> [CLIENT]
To do this, here's what you need to do:

Nginx Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400,000 to 500,000 requests per second (clustered), most what i saw is 50,000 to 80,000 (non-clustered) requests per second and 30% CPU load, course, this was 2xIntel Xeon with HT enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

First, you will need to install nginx, my way to install nginx is compiling it from source, but for now we will use apt-get

@baysao
baysao / syslog-ng.conf
Created April 7, 2016 06:03 — forked from mbijon/syslog-ng.conf
Syslog nginx without $ or patching, http://syshero.org/post/68174083489/nginx-syslog-ing-without-breaking-the-bank-or-patching (1) directory/fifo structure: mkdir -p /srv/logs/ mkfifo /srv/logs/access.log mkfifo /srv/logs/error.log (2) nginx conf: error_log /srv/logs/error.log; access_log /srv/logs/access.log; (3) remember to start syslog-ng bef…
source s_nginx_20 { pipe("/srv/logs/access.log" program_override("nginx-access-log")); };
source s_nginx_21 { pipe("/srv/logs/error.log" program_override("nginx-error-log")); };
filter f_nginx_20 { match("nginx-access-log" value("PROGRAM")); };
filter f_nginx_21 { match("nginx-error-log" value("PROGRAM")); };
destination d_remote { tcp("central.syslog", port(514)); };
log { source(s_nginx_20); filter(f_nginx_20); destination(d_messages); };
log { source(s_nginx_21); filter(f_nginx_21); destination(d_messages); };
# https://www.erlang-solutions.com/downloads/download-erlang-otp
# wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
# sudo dpkg -i erlang-solutions_1.0_all.deb
deb http://packages.erlang-solutions.com/ubuntu trusty contrib
deb http://packages.erlang-solutions.com/ubuntu saucy contrib
deb http://packages.erlang-solutions.com/ubuntu precise contrib
wget http://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc
sudo apt-key add erlang_solutions.asc
@baysao
baysao / gist:59d5f5d7fb4bbd48f03a
Created January 3, 2016 13:22 — forked from klovadis/gist:5170446
Two Lua scripts for Redis to turn HGETALL and HMGET into dictionary tables
-- gets all fields from a hash as a dictionary
local hgetall = function (key)
local bulk = redis.call('HGETALL', key)
local result = {}
local nextkey
for i, v in ipairs(bulk) do
if i % 2 == 1 then
nextkey = v
else
result[nextkey] = v