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
# read lines | |
lines = open('file-name.txt').readlines() | |
# change a specific line | |
# e.g. using regular expression | |
p = re.compile(...) | |
for i in range(len(lines)): | |
m = p.match(lines[i]) | |
if m: | |
# m.group(0) or m.group(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
#!/bin/sh | |
rm -f cpu-output.txt | |
rm -f gpu-output.txt | |
# run benchmarks | |
../out/Release/bench -config 8888 -repeat 100 -match blur_size | tee cpu-output.txt | |
../out/Release/bench -config GPU -repeat 100 -match blur_size | tee gpu-output.txt | |
for i in 1 2 4 8 16 32 64 128 ; do |
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
///////////////////////////////////////////////////////////////////////////// | |
/* the callbacks */ | |
struct data { | |
char trace_ascii; /* 1 or 0 */ | |
}; | |
struct data config; | |
static | |
void dump(const char *text, |
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
import os | |
import re | |
files = [] | |
for (root, dirnames, filenames) in os.walk('.'): | |
if len(filenames) != 0: | |
for one in filenames: | |
files.append(os.path.join(root, one)) | |
isPng = re.compile(r'.*\.png$') |
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
import Image | |
import sys | |
import os | |
imagefilename = sys.argv[1] | |
im = Image.open(imagefilename) | |
tim = Image.new('RGBA', im.size) |
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
/* extracted from http://oopweb.com/CPP/Documents/CPPHOWTO/Volume/C++Programming-HOWTO-7.html | |
* use this hand-crafted function if boost can't be used in the project. | |
*/ | |
void tokenize(const string& str, | |
vector<string>& tokens, | |
const string& delimiters = " ") | |
{ | |
// Skip delimiters at beginning. | |
string::size_type lastPos = str.find_first_not_of(delimiters, 0); | |
// Find first "non-delimiter". |
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
.DS_Store | |
Library/ | |
Temp/ | |
Build/ | |
*.csproj | |
*.sln | |
*.userprefs | |
*.pidb | |
*.unityproj |
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
System.Text.Encoding.UTF8.GetString(bytes); | |
using System.Text; | |
Encoding.ASCII.GetBytes(words); |
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
[Extension] | |
public static class ListUtils | |
{ | |
[Extension] | |
public static void Shuffle<T>(IList<T> list) | |
{ | |
int count = list.Count; | |
while (count > 1) | |
{ | |
count--; |
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 <algorithm> | |
#include <functional> | |
#include <cctype> | |
#include <locale> | |
// trim from start | |
static inline std::string <rim(std::string &s) { | |
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace)))); | |
return s; | |
} |
OlderNewer