Skip to content

Instantly share code, notes, and snippets.

@xire-
xire- / payment_solver.py
Created March 20, 2018 16:38
payment solver
#!/usr/bin/env python3
# -*- coding: utf8 -*-
from collections import defaultdict
from itertools import permutations
class PaymentSolver:
def __init__(self, people):
# if X owe Y N euro,
# then Y owe X -N euro
@xsleonard
xsleonard / gist:7341172
Created November 6, 2013 18:10
hex string to byte array, C
unsigned char* hexstr_to_char(const char* hexstr)
{
size_t len = strlen(hexstr);
IF_ASSERT(len % 2 != 0)
return NULL;
size_t final_len = len / 2;
unsigned char* chrs = (unsigned char*)malloc((final_len+1) * sizeof(*chrs));
for (size_t i=0, j=0; j<final_len; i+=2, j++)
chrs[j] = (hexstr[i] % 32 + 9) % 25 * 16 + (hexstr[i+1] % 32 + 9) % 25;
chrs[final_len] = '\0';
@plentz
plentz / nginx.conf
Last active April 24, 2024 11:15
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048