Skip to content

Instantly share code, notes, and snippets.

#coding:utf-8
# https://gist.github.com/opensourcegeek/9822127
from gevent import monkey
monkey.patch_all()
import logging
import gevent
from gevent.queue import Queue, Empty
import pymysql as db
@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 / gevent_task_queue.py
Last active April 22, 2018 17:40
a simple gevent task queue
#coding:utf-8
from gevent import monkey
monkey.patch_all()
import logging
import gevent
logging.basicConfig(level=logging.DEBUG)
LOGGER = logging.getLogger("GeventTaskQueue")
from gevent.queue import Queue, Empty
@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 / gevent_celery.py
Created October 19, 2015 02:30
模仿 celery 的gevent celery
#coding:utf-8
from gevent import monkey
monkey.patch_all()
import logging
import gevent
import datetime
logging.basicConfig(level=logging.DEBUG)
LOGGER = logging.getLogger("GeventCelery")
@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"