This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main(int argc, char const *argv[]) | |
{ | |
int i; | |
for(i=0; i<2; i++){ | |
fork(); | |
printf("-"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
/* | |
gcc compile with -fno-stack-protector to disable "stack Smashing Protection" | |
*/ | |
int main(void) | |
{ | |
char buff[6]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
def insert_sort(array): | |
if len(array) <= 1: | |
return | |
for i in range(1, len(array)): | |
j = i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
def quick_sort(sort_list): | |
if len(sort_list) <= 1: | |
return sort_list | |
m = sort_list[0] | |
return quick_sort(filter(lambda x: x<=m, sort_list[1:])) + [m] + \ | |
quick_sort(filter(lambda x: x>m, sort_list[1:])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
def bubble_sort(sort_list): | |
length = len(sort_list) | |
while length > 1: | |
for i in range(1, length): | |
if sort_list[i] < sort_list[i-1]: | |
sort_list[i], sort_list[i-1] = sort_list[i-1],sort_list[i] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
from gevent import monkey | |
monkey.patch_all() | |
import os | |
import tornado | |
import logging | |
import tornado.wsgi | |
import tornado.httpserver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
typedef unsigned char * byte_pointer; | |
int showBigOrLittleEnd() | |
{ | |
int i = 0x01; | |
byte_pointer bp = (byte_pointer) &i; | |
if (bp[0] == 0x01) | |
return 1; |