Skip to content

Instantly share code, notes, and snippets.

@clckwrkbdgr
clckwrkbdgr / fieldbook.py
Created June 20, 2016 10:47
Fieldbook API example using Python: read a dictionary of values from fieldbook sheet
POST_URL='https://api.fieldbook.com/v1/<USER_ID>/<SHEET_ID>'
KEY='...'
SECRET='...'
def get_fieldbook_json():
try:
response = requests.get(POST_URL, auth=(KEY, SECRET))
if response.status_code != 200:
return None
return response.json()
@clckwrkbdgr
clckwrkbdgr / pastebin.py
Created March 6, 2016 16:20
Using Pastebin as a free online data storage
import requests
import xml.etree.ElementTree as ET
import sys
class Pastebin:
def __init__(self, api_key, user_key):
self.api_key, self.user_key = api_key, user_key
self.session = requests.session()
def _post(self, option, data = None):
data = data.copy() if data else {}
@clckwrkbdgr
clckwrkbdgr / solve_linear
Created June 30, 2014 08:36
Solve linear system in Python.
def minor(a, row, col):
result = []
for line in a[:row] + a[row+1:]:
result.append(line[:col] + line[col+1:])
return result
def determinant(a):
if len(a) == 2:
return a[0][0] * a[1][1] - a[1][0] * a[0][1]
result = 0
@clckwrkbdgr
clckwrkbdgr / Makefile
Created May 22, 2014 11:48
Simple makefile template for C++ project
BIN = wted
LIBS = -lchthon2
SOURCES = $(wildcard *.cpp)
OBJ = $(addprefix tmp/,$(SOURCES:.cpp=.o))
#WARNINGS = -pedantic -Werror -Wall -Wextra -Wformat=2 -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wuninitialized -Wunused -Wfloat-equal -Wundef -Wno-endif-labels -Wshadow -Wcast-qual -Wcast-align -Wconversion -Wsign-conversion -Wlogical-op -Wmissing-declarations -Wno-multichar -Wredundant-decls -Wunreachable-code -Winline -Winvalid-pch -Wvla -Wdouble-promotion -Wzero-as-null-pointer-constant -Wuseless-cast -Wvarargs -Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-attribute=noreturn -Wsuggest-attribute=format
CXXFLAGS = -MD -MP -std=c++0x $(WARNINGS)
all: $(BIN)
@clckwrkbdgr
clckwrkbdgr / xpm2sdl
Created April 21, 2014 15:04
Loading XPM data into SDL2 texture.
SDL_Texture * Sprite::load(SDL_Renderer * renderer, const char ** xpm, int size)
{
SDL_Texture * result = 0;
try {
std::vector<std::string> xpm_lines(xpm, xpm + size);
Chthon::Pixmap pixmap;
pixmap.load(xpm_lines);
SDL_Surface * surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
pixmap.pixels.width(), pixmap.pixels.height(), 32,
0x00ff0000,