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
template <class T> | |
class DeleteObj | |
{ | |
public: | |
void operator()(T*obj) { delete obj; } | |
}; | |
// Sample usage ... | |
class Foo |
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
for_each(foos.begin(), foos.end(), mem_fun(&Foo::doStuff)); | |
// Example ... | |
class Foo | |
{ | |
public: | |
Foo(); | |
void doStuff(); |
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 <iostream> | |
#include <fstream> | |
#include <string> | |
#include <stdint.h> | |
#include <pcre.h> | |
using namespace std; | |
uint32_t cpufreq() | |
{ |
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
// Taken from: http://www.cplusplus.com/doc/tutorial/files/ | |
// writing a text file | |
#include <iostream> | |
#include <fstream> | |
using namespace std; | |
int main () { | |
ofstream myfile ("example.txt"); | |
if (myfile.is_open()) |
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
// Taken from http://www.cplusplus.com/doc/tutorial/files/ | |
// reading a text file | |
#include <iostream> | |
#include <fstream> | |
#include <string> | |
using namespace std; | |
int main () { | |
string line; |
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
" indendentation specific to file types | |
:filetype plugin indent on | |
filetype plugin on | |
" spaces instead of tabs | |
"set expandtab | |
" show line numbers | |
"set number |
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
# From: http://www.noulakaz.net/weblog/2007/03/18/a-regular-expression-to-check-for-prime-numbers/ | |
def is_prime(n) | |
("1" * n) !~ /^1?$|^(11+?)\1+$/ | |
end |
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
from Crypto.Cipher import AES | |
key='\x63\x5b\x76\xd1\x71\x5c\xdf\x2a\x69\x99\xc9\x0f\x3b\x23\x13\x02' | |
iv='\x4c\x84\x2e\x40\x8b\xb0\x73\x01\xe4\x64\x92\x94\xfa\x5b\x73\x0b' | |
obj = AES.new(key, AES.MODE_CBC, iv) | |
obj.decrypt(message) |
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
#!/usr/bin/python -d | |
import argparse | |
from subprocess import call | |
def copyfile(src, dst): | |
call(["cp", src, dst]) | |
parser = argparse.ArgumentParser(description='Copy files from a list to a destination directory') | |
parser.add_argument('filelist', help="File containing list of filenames to copy") |
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
data = [1,2,2,3,4,4,5,6,5,7] | |
no_dups = list(set(data)) |
OlderNewer