This file contains hidden or 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
import time | |
import os | |
for t in range(60)*100: | |
for i in range(1,10,2)+range(7,0,-2): | |
print ' '*t+'\033[1;5;3'+str(t%5+1)+';4'+str(t%5+1)+'m'+'*'*i+'\033[m' | |
time.sleep(0.1) | |
os.system('clear') |
This file contains hidden or 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
Use strace and ltrace to trace the runtime behavior |
This file contains hidden or 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
#!/usr/bin/env python | |
#-*- encoding: utf8 | |
# sudo easy_install PIL | |
import Image | |
import ImageFont | |
import ImageDraw | |
import sys | |
import os |
This file contains hidden or 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
#!/bin/bash | |
trap "echo TRAP!!; exit" SIGTERM SIGINT SIGHUP | |
for (( i=0; i<5; i=i+1 )) | |
do | |
echo $i | |
sleep 1 | |
done |
This file contains hidden or 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> | |
#include <unistd.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
void redirect_to(char *filename) | |
{ | |
int fd = open(filename, O_RDWR | O_CREAT, 0666); |
This file contains hidden or 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
#pragma once | |
#include <utility> | |
// | |
// Quick sort for single linked list | |
// | |
// Template arguments: | |
// T: node's pointer type | |
// Next: function/functor to get next node | |
// Compare: functor to compare 2 arguments | |
// |
This file contains hidden or 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
#ifndef MYCLASS_H | |
#define MYCLASS_H | |
#include <boost/serialization/export.hpp> | |
#include <boost/serialization/vector.hpp> | |
using namespace std; | |
class A | |
{ |
This file contains hidden or 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 <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <boost/lambda/lambda.hpp> | |
#include <boost/lambda/bind.hpp> | |
using namespace std; | |
using namespace boost::lambda; | |
int main(int argc, const char *argv[]) |
This file contains hidden or 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 <list> | |
#include <utility> | |
#include <iostream> | |
using namespace std; | |
template<class T1, class T2> | |
list< pair<T1,T2> > zip(const list<T1>& container1, const list<T2>& container2) | |
{ | |
list< pair<T1,T2> > result; |
This file contains hidden or 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 "cutility.h" | |
void gotoxy(int x, int y) | |
{ | |
static HANDLE hConsole = GetStdHandle( STD_OUTPUT_HANDLE ); | |
COORD coord={x, y}; | |
SetConsoleCursorPosition(hConsole, coord); | |
} | |
void setcolor(const char *fg, const char *bg) |