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
#Three-way QuickSort in Python | |
def quicksort(a): | |
if len(a) == 0: | |
return [] | |
p = a[(len(a)-1)//2] | |
less = quicksort([x for x in a if x < p]) | |
greater = quicksort([x for x in a if x > p]) | |
equal = [x for x in a if x == p] | |
return less + equal + greater |
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 | |
# Copyright (C) 2009 Mauricio Teixeira. | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. |
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 datetime | |
import time | |
def from_string_to_timestamp(st): | |
if st.find('-') != -1: | |
splitted = st.split('-') | |
else: | |
splitted = st.split('.') | |
try: |
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 urllib2 | |
import json | |
# Whatever structure you need to send goes here: | |
jdata = json.dumps({"username":"...", "password":"..."}) | |
urllib2.urlopen("http://www.example.com/", jdata) |
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 random | |
random.seed() | |
hash = random.getrandbits(128) | |
print "hash value: %016x" % hash |
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
n = input("n = ") | |
a = range(n+1) | |
a[1] = 0 | |
lst = [] | |
i = 2 | |
while i <= n: | |
if a[i] != 0: | |
lst.append(a[i]) | |
for j in xrange(i, n+1, i): |
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
// Compile with g++ -o multithreading.o multithreading.cc -lpthread | |
#include <pthread.h> | |
#include <errno.h> | |
#include <signal.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
#include <unistd.h> | |
#include <string.h> |
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
// function template | |
#include <iostream> | |
using namespace std; | |
template <class T> | |
T GetMax (T a, T b) { | |
T result; | |
result = (a>b)? a : b; | |
return (result); | |
} |
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
# Set up the prompt | |
autoload -Uz promptinit | |
promptinit | |
prompt adam1 | |
setopt histignorealldups sharehistory | |
# Use emacs keybindings even if our EDITOR is set to vi | |
bindkey -e |
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
(setq org-directory "~/org/") | |
(load-file "/home/gennad/.emacs.d/emacs-for-python/epy-init.el") | |
;; To require | |
;;(add-to-list 'load-path "~/.emacs.d/http") | |
;;(require 'http-post-curl) | |
;;(require 'http-twiddle) | |
;;(load-file "/home/gennad/.emacs.d/http-post-curl.el") |