Skip to content

Instantly share code, notes, and snippets.

@ls0f
ls0f / imagemagick-install-steps
Created September 25, 2015 08:17 — forked from rodleviton/imagemagick-install-steps
Installing Image Magick on Ubuntu 14.04
sudo -i
cd
apt-get install build-essential checkinstall && apt-get build-dep imagemagick -y
wget http://www.imagemagick.org/download/ImageMagick-6.8.7-7.tar.gz
tar xzvf ImageMagick-6.8.9-1.tar.gz
cd ImageMagick-6.8.9-1/
./configure --prefix=/opt/imagemagick-6.8 && make
checkinstall
@ls0f
ls0f / buffer_overflow_example.c
Created October 9, 2015 03:46
buffer overflow attack example
#include <stdio.h>
#include <string.h>
/*
gcc compile with -fno-stack-protector to disable "stack Smashing Protection"
*/
int main(void)
{
char buff[6];
@ls0f
ls0f / fork_buffer.c
Created October 9, 2015 13:03
fork and buffer
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char const *argv[])
{
int i;
for(i=0; i<2; i++){
fork();
printf("-");
}
@ls0f
ls0f / progress_bar.py
Created October 10, 2015 02:59
Text Progress Bar in the Console
#coding:utf-8
# http://stackoverflow.com/questions/3173320/text-progress-bar-in-the-console
import sys
import time
i = 0
while i<100:
time.sleep(0.3)
i += 1
#sys.stdout.write("\r{}".format(i))
@ls0f
ls0f / blur.sh
Last active October 16, 2015 07:33
image magick remove backgroud and set the backgroud transparent
#!/bin/bash
convert $1 -channel A -blur 1x65000 -level 50x100% \
-channel rgba $2
@ls0f
ls0f / one_process.py
Last active October 18, 2015 03:30
Prevent the script repeatedly run
import os
import inspect
import atexit
from functools import wraps
class OneProcess(object):
def __init__(self):
self.caller_file_name = inspect.getouterframes(
@ls0f
ls0f / backup_mongo.sh
Last active November 5, 2015 02:35
mongodb backup
#!/bin/bash
BACKUP_DB="xx"
DUMP_CMD="/usr/bin/mongodump"
HOST="127.0.0.1"
PORT="27017"
TIMESTAMP=`date +%F-%H%M`
BACKUP_DIR="/opt/data/backup"
cd $BACKUP_DIR
BACKUP_NAME_PREFIX="app-db"
@ls0f
ls0f / proxy_google.conf
Last active November 7, 2015 04:36
反代google.co.jp
proxy_cache_path /data/nginx/cache/ levels=1:2 keys_zone=one:10m max_size=10g;
proxy_cache_key "$host$request_uri";
upstream google_jp {
server 173.194.38.216:80;
server 173.194.38.215:80;
server 173.194.38.217:80;
server 173.194.38.218:80;
}
@ls0f
ls0f / nginx_auth.py
Last active November 10, 2015 08:49
gen http auth passwd file
import os
import sys
import random
# more info
# http://trac.edgewall.org/export/10770/trunk/contrib/htpasswd.py
# We need a crypt module, but Windows doesn't have one by default. Try to find
# one, and tell the user if we can't.
try:
#!/bin/bash
welcome=(
'佛祖保佑 永无BUG'
'你好啊单身狗'
'壮士,干了这碗鸡汤!'
'上线了吗?'
'法海,你的头发怎么那么长!'
'少壮不努力,长大做挨踢.'
'佛祖,我好烦.'