Skip to content

Instantly share code, notes, and snippets.

@DiKorsch
DiKorsch / coinbase.py
Last active October 30, 2015 07:10
Coinbase API in python 2.7
import hashlib, hmac, urllib2, time, json, requests
COINBASE_ENDPOINT = "https://coinbase.com/api/v1"
FORMAT = "json"
# store these in a secure place... this is only for demo purpose
KEY = "KEY"
SECRET = "SECRET"
@DiKorsch
DiKorsch / hwloc-ex.c
Created November 30, 2014 09:32
hwloc example from a presentation for a NUMA seminar
/* Example hwloc API program.
*
* See other examples under doc/examples/ in the source tree
* for more details.
*
* Copyright © 2009-2014 Inria. All rights reserved.
* Copyright © 2009-2011 Université Bordeaux 1
* Copyright © 2009-2010 Cisco Systems, Inc. All rights reserved.
* See COPYING in top-level directory.
*
@DiKorsch
DiKorsch / libnuma-ex.c
Last active March 8, 2019 17:21
libnuma example from a presentation for a NUMA seminar
#include <numa.h>
#include <stdio.h>
int main(void)
{
if(numa_available() < 0){
printf("System does not support NUMA API!\n");
}
int n = numa_max_node();
int size = 1024*1024;
@DiKorsch
DiKorsch / win-numa.c
Last active August 29, 2015 14:10
windows NUMA API example from a presentation for a NUMA Seminar
/* origin: http://technet.microsoft.com/de-de/ms683194%28v=vs.80%29 */
#include <windows.h>
#include <malloc.h>
#include <stdio.h>
#include <tchar.h>
typedef BOOL (WINAPI *LPFN_GLPI)(
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION,
PDWORD);
#include "rotation.hpp"
using namespace cv;
using namespace std;
void rotate(const Mat src, Mat &dest, double angle, int borderMode, const Scalar &borderValue){
int w = src.size().width, h = src.size().height;
Size2d new_size = Size2d(abs(w * COS((int)angle % 180)) + abs(h * SIN((int)angle % 180)), abs(w * SIN((int)angle % 180)) + abs(h * COS((int)angle % 180)));
@DiKorsch
DiKorsch / forms.py
Created August 19, 2015 06:47
PayPal payment with OTP verification form
from paypal.standard.forms import PayPalPaymentsForm as PPPF
from django import forms
class OTPForm(forms.Form):
code = forms.CharField(label = "TOTP Code")
def clean_code(self):
code = self.cleaned_data['code']
if not check_otp(code): # use libraries like onetimepass
@DiKorsch
DiKorsch / BoostConfig.cmake.in
Last active August 29, 2015 14:27
CMakeLists.txt for Boost to compile some libraries with cmake (eg for Android)
set(Boost_INCLUDE_DIRS @Boost_INCLUDE_DIRS@)
set(Boost_LIBRARIES @Boost_LIBRARIES@)
link_directories(@Boost_LINK_DIRS@)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} @Boost_C_FLAGS@")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} @Boost_CXX_FLAGS@")
from converter import extract
from os import path
import argparse, simplejson as json
def generateJson(lectureId, outdir, images):
if not outdir.endswith("/"): outdir += "/"
sync_file = path.join(outdir, "sync")
json_obj = {"lectureId": lectureId, "images": []}
with open(sync_file) as f:
for line in f:
@DiKorsch
DiKorsch / run.py
Last active August 16, 2022 12:09
Scan files under Windows and save them under filename present in the clipboard
"""
- python2.7 32bit installieren (https://www.python.org/ftp/python/2.7.12/python-2.7.12.msi)
- C:\python\pip install pyperclip twain pillow
- C:\python\python.exe run.py
"""
import pyperclip, twain, os
from os.path import isdir, isfile, dirname, abspath
from PIL import Image
@DiKorsch
DiKorsch / chainer_caffe_wrapper.py
Last active August 6, 2017 10:55
Some useful utility scripts
from chainer.functions.caffe import CaffeFunction
import pickle, logging
from os.path import isfile
class CaffeNetWrapper(object):
def __init__(self, caffe_model, chainer_model, force_caffe_load = False):
super(CaffeNetWrapper, self).__init__()
if not force_caffe_load and isfile(chainer_model):
logging.info("loading chainer model from \"{}\"".format(chainer_model))