Skip to content

Instantly share code, notes, and snippets.

@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
#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 / 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);
@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 / 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 / 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"