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
class Trie: | |
def __init__(self): | |
self.trie = dict() | |
def insert(self, key, value): | |
p = self.trie | |
for c in key: | |
if c not in p: p[c] = dict() | |
p = p[c] | |
p[None] = value |
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 | |
def generate_permutation(a_count, b_count, c_count, string_length, prefix=""): | |
if a_count + b_count + c_count == string_length: | |
print prefix | |
return | |
generate_permutation(a_count + 1, b_count, c_count, string_length, "a" + prefix) | |
generate_permutation(a_count, b_count + 1, c_count, string_length, "b" + prefix) | |
generate_permutation(a_count, b_count, c_count + 1, string_length, "c" + prefix) |
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 | |
import cairo | |
sfc = cairo.PDFSurface( open("file.pdf", "w"), 144, 144 ) | |
cr = cairo.Context(sfc) | |
cr.set_line_width(1) | |
cr.set_source_rgb(0.5, 0.5, 0.5) | |
cr.move_to(10, 10) |
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 Figure = Triangle (Float side) | |
| Square (Float side) | |
| Circle (Float radius) | |
perimeter Triangle side = 3 * side | |
perimeter Square side = 4 * side | |
perimeter Circle radius = 2 * pi * radius |
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 <chrono> | |
#include <iostream> | |
#include <vector> | |
#include <QtCore/QVector> | |
template <typename container> | |
void test(const char* desc) | |
{ | |
auto t1 = std::chrono::high_resolution_clock::now(); |
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
uint64_t fnvhash(const char* data, size_t size) { | |
uint64_t hsh = 14695981039346656037L; | |
for (size_t i = 0; i < size; ++i) { | |
hsh = (hsh * 1099511628211L) ^ (uint64_t)(data[i]); | |
} | |
return hsh; | |
} | |
// Calculating the hash for QString | |
template <> |
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
pub fn enumerate_windows<F>(mut callback: F) | |
where F: FnMut(HWND) -> bool | |
{ | |
let mut trait_obj: &mut FnMut(HWND) -> bool = &mut callback; | |
let closure_pointer_pointer: *mut c_void = unsafe { mem::transmute(&mut trait_obj) }; | |
let lparam = closure_pointer_pointer as LPARAM; | |
unsafe { EnumWindows(Some(enumerate_callback), lparam) }; | |
} |
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
$ hexdump -v -s 6 -e '4/1 "%d \t" "\t\t" 2/2 "%d \t" "\t\t" 2/4 "%d \t"' -e '"\n"' icon.ico | head -n 5 |
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
[target.x86_64-pc-windows-gnu] | |
linker = "x86_64-w64-mingw32-gcc" | |
rustflags = ["-L/usr/x86_64-w64-mingw32/lib", "-lstatic=ssl", "-lstatic=crypto", "-lgdi32"] | |
[target.x86_64-apple-darwin] | |
linker = "/usr/local/osx-ndk-x86/bin/x86_64-apple-darwin15-clang" | |
rustflags = ["-C", "link-arg=-mmacosx-version-min=10.7"] |
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
find . -type f -exec sed -i 's@http://timestamp.verisign.com/scripts/timstamp.dll@http://sha256timestamp.ws.symantec.com/sha256/timestamp@g' {} + |
OlderNewer