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 django.db.models import Q | |
from django.views.generic import ListView | |
import itertools | |
class BaseSearchView(ListView): | |
search_fields = [] | |
def get_search_fields(self): | |
return self.search_fields | |
query_key = 'q' |
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 itertools | |
def fizzbuzz(): | |
for i in itertools.count(1): | |
fizz = i % 3 == 0 | |
buzz = i % 5 == 0 | |
if fizz and buzz: | |
yield 'fizz buzz' | |
elif fizz: |
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 bitcoinrpc.connection import BitcoinConnection | |
con = BitcoinConnection(host='127.0.0.1', port=18332, user='u', password='p') | |
destination_addr = 'mh5YsB8cSLT2NxLKkdaZANBqhLSDgMFgGj' | |
num_signatures = 2 | |
signer_addr = 'mfcWQhBtWGPcSBPiPDeUJZ5n1Ud7XF2hSK' | |
additional_signer_addr = 'mr37a4xtZZByapa9neEPC3oYLxbEaFyCkP' | |
amount = 20.0 |
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
def start_rql(rql, access_token): | |
base_url = 'https://api.rollbar.com' | |
start_job_url = base_url + '/api/1/rql/jobs?access_token=' + access_token | |
body = json.dumps({'query_string': rql}) | |
resp = requests.post(start_job_url, data=body, headers={'Content-Type': 'application/json'}).json() | |
get_job_res = '{}/api/1/rql/job/{}?access_token={}&expand=result'.format(base_url, resp['result']['id'], access_token) | |
def getter(): | |
return requests.get(get_job_res).json()['result']['result']['rows'] | |
return getter |
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
def get_classname(): | |
return traceback.extract_stack()[-2][2] # in inner call | |
def get_classname_for_method_decorator(): | |
return traceback.extract_stack()[-3][2] # in inner call | |
def decorator(func): | |
classname = get_classname_for_method_decorator() | |
return func |
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
#pragma once | |
template < typename T > class SP | |
{ | |
private: | |
T* pData; // pointer | |
int* refcnt; // Reference count | |
public: | |
SmartPointer() : pData(0), refcnt(0) | |
{ |
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
me@hardy:~$ sudo hcitool scan | |
Scanning ... | |
00:02:C7:7D:F5:17 BlueGPS 7DF517 | |
me@hardy:~$ sudo rfcomm bind /dev/rfcomm0 00:02:C7:7D:F5:17 1 | |
me@hardy:~$ ls -l /dev/rfcomm0 | |
crw-rw---- 1 root dialout 216, 0 2008-12-14 23:15 /dev/rfcomm0 |
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
generate drop all tables statement | |
select 'drop table if exists "' || tablename || '" cascade;' from pg_tables where schemaname = 'public'; |
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 backtrace | |
{ | |
boost::shared_array<void*> m_backtrace; | |
size_t m_trace_size; | |
public: | |
static const int DEFAULT_STACK_DEPTH = 100; | |
static const int DEFAULT_EXCLUDE_FIRST_FRAMES_COUNT = 1; | |
typedef std::vector<std::string> stack_type; |
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
tar -cvpj /path/to/directory | openssl aes-256-cbc -kfile /path/to/enc.key | split -d -b 4000m - backup.tar.bz2.enc. | |
cat backup.tar.bz2.enc.* | openssl aes-256-cbc -d -kfile /path/to/enc.key | tar xvjf - |
NewerOlder