Skip to content

Instantly share code, notes, and snippets.

View AndreiBarsan's full-sized avatar

Andrei Bârsan AndreiBarsan

View GitHub Profile
@AndreiBarsan
AndreiBarsan / simplex_search_from_notebook.py
Created April 23, 2020 03:00
Compares hacky gradient descent to Nelder-Mead search (simplex search)
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
matplotlib.rcParams['xtick.direction'] = 'out'
matplotlib.rcParams['ytick.direction'] = 'out'
def rosenbrock(x, y, a=1.0, b=100.0):
return (a - x) ** 2 + b * (y - x * x) ** 2
@AndreiBarsan
AndreiBarsan / shrink-pdf.sh
Created August 23, 2017 08:39
Shrinks the PDF passsed to it
#!/usr/bin/env bash
# Heavily based on: https://softwarerecs.stackexchange.com/questions/18442/command-line-pdf-image-compression-optimizer, but less aggressive.
gs \
-o smaller-downsampled.pdf \
-sDEVICE=pdfwrite \
-dCompressPages=true \
-dCompressFonts=true \
-dDownsampleColorImages=true \
-dDownsampleGrayImages=true \
@AndreiBarsan
AndreiBarsan / woooo
Created February 11, 2015 19:10
La mulți ani, Edy! :D
#include<stdio.h>
#define K putchar
#define TOP 0xFF000
#define KEK 0xFF0
char m[]={0xa, 0x21, 0x23, 0x8, 0x32, 0x19, 0x32, 0x19, 0x3b, 0x10, 0x62, 0x49, 0x20, 0xb, 0x2b, 0x0, 0x30, 0x1b, 0x36, 0x1d, 0x2a, 0x1, 0x26, 0xd, 0x23, 0x8, 0x3b, 0x10, 0x62, 0x45, 0x36, 0x49, 0x2d, 0xd, 0x62, 0xc, 0x3b, 0x8, 0x2d, 0x1b, 0x37, 0x49, 0x63, 0x2c, 0x62, 0xd, 0x62, 0x10, 0x62, 0x48, 0x48, 0x63};
long i=0;double MM=0.0625;char *qq; char d=61;int q;
void main() { char cc=sizeof(m); int s[]={0x342691};int *O=s;char vv=cc;goto k;
rev:for(;i<vv;) { K(m[i++] ^ (
(s[(long)qq] & TOP)>>12)); {
i++; }; }