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
# Problem description: http://www.careercup.com/question?id=14968041 | |
def find_coil(n, x, y, dxs, dys): | |
nsteps = [] | |
for nstep in xrange(2, n - 1, 2): | |
nsteps.append(nstep) | |
nsteps.append(nstep) | |
nsteps.append(nstep + 1) | |
rs = [y * n + x + 1] | |
idx = 0 |
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
/* | |
# compilation | |
$ g++ queue.cpp -O2 -g -pthread -o queue_without_lock -DLOCK_FREE | |
$ g++ queue.cpp -O2 -g -pthread -o queue_with_lock | |
# execution time | |
$ time ./queue_with_lock | |
real 0m0.035s 0m0.153s 0m0.055s | |
user 0m0.040s 0m0.270s 0m0.070s | |
sys 0m0.020s 0m0.030s 0m0.030s |
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
# from http://stackoverflow.com/questions/3096259/bash-command-to-sum-a-column-of-numbers | |
$ paste -sd+ infile|bc |
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
"Custom syntax | |
hi DATE guifg=green | |
syn match DATE /\[201\d\/\d\d\/\d\d\]/ | |
hi IMPORTANT guifg=red | |
syn match IMPORTANT /(\*)/ |
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 -*- | |
import getpass | |
import gdata | |
import gdata.docs.service | |
user = raw_input('username: ') | |
passwd = getpass.getpass('password: ') |
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
/* Copyright (C) 1991,1992,1996,1997,1999,2004 Free Software Foundation, Inc. | |
This file is part of the GNU C Library. | |
Written by Douglas C. Schmidt ([email protected]). | |
The GNU C Library is free software; you can redistribute it and/or | |
modify it under the terms of the GNU Lesser General Public | |
License as published by the Free Software Foundation; either | |
version 2.1 of the License, or (at your option) any later version. | |
The GNU C Library is distributed in the hope that it will be useful, |
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
(autoconf --version) < /dev/null > /dev/null 2>&1 || { | |
echo | |
echo "You must have autoconf installed to compile $PROJECT." | |
echo "Install the appropriate package for your distribution," | |
echo "or get the source tarball at http://ftp.gnu.org/gnu/autoconf/" | |
DIE=1 | |
} | |
autoconf || exit $? |
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
// #1 | |
void add_node(Node *node, Node *new_node) { | |
if (new_node->value <= node->value) { | |
if (node->left == NULL) { | |
node->left = new_node; | |
return; | |
} | |
add_node(node->left, new_node); | |
return; | |
} |
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/perl | |
use strict; | |
use warnings; | |
use JavaScript::Beautifier qw/js_beautify/; | |
if ($#ARGV != 1) { | |
print "jsindent <in file> <out file>\n"; |
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/python | |
# source: http://www.reddit.com/r/programming/comments/hql8b/looks_like_it_for_the_last_few_months_i_have_had/c1xkcdd | |
import glob | |
import os | |
import sys | |
from PIL import Image | |
EXTS = 'jpg', 'jpeg', 'JPG', 'JPEG', 'gif', 'GIF', 'png', 'PNG' |