Skip to content

Instantly share code, notes, and snippets.

View blubberdiblub's full-sized avatar
🤯

Niels Boehm blubberdiblub

🤯
View GitHub Profile

Keybase proof

I hereby claim:

  • I am blubberdiblub on github.
  • I am blubberdiblub (https://keybase.io/blubberdiblub) on keybase.
  • I have a public key ASDnLeMPqObdhBF4h4vLP_I0oSQbreDqqBdn2AM9sNeXIAo

To claim this, I am signing this object:

@blubberdiblub
blubberdiblub / conversion.cpp
Last active September 1, 2019 02:59
Integral promotion and usual arithmetic conversion
#include <cstdint>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
#include <typeinfo>
#include <cxxabi.h>
@blubberdiblub
blubberdiblub / findcerts.py
Last active June 17, 2019 08:58
find-certs
#!/usr/bin/env python3
import base64
import pickle
import sys
from binascii import crc32
from datetime import timezone
import pathvalidate
@blubberdiblub
blubberdiblub / Loop4.java
Last active September 18, 2018 06:55
linear sweep variant #4
private static void sweepLinear(double min, double max, int num_intervals) {
for (int i = 0; i <= num_intervals; i++) {
int j = num_intervals - i;
double value = (max * i + min * j) / num_intervals;
doSomethingWithValue(value);
}
}
/* Output:
@blubberdiblub
blubberdiblub / Loop3.java
Last active September 18, 2018 06:55
linear sweep variant #3
private static void sweepLinear(double min, double max, int num_intervals) {
for (int i = 0; i <= num_intervals; i++) {
double p = (double)i / (double)num_intervals;
double q = 1.0 - p;
double value = max * p + min * q;
doSomethingWithValue(value);
}
}
@blubberdiblub
blubberdiblub / Loop2.java
Last active September 18, 2018 06:58
linear sweep variant #2
private static void sweepLinear(double min, double max, int num_intervals) {
double step = (max - min) / num_intervals;
double value = min;
for (int i = 0; i <= num_intervals; i++) {
doSomethingWithValue(value);
value += step;
}
}
@blubberdiblub
blubberdiblub / Loop1.java
Last active September 18, 2018 06:57
linear sweep variant #1
private static void sweepLinear(double min, double max, int num_intervals) {
double step = (max - min) / num_intervals;
double value = min;
while (value <= max) {
doSomethingWithValue(value);
value += step;
}
}
@blubberdiblub
blubberdiblub / Loop.java
Created September 18, 2018 06:47
loop framework
class Loop {
public static void main(String[] args) {
sweepLinear(1.5, 2.5, 2);
System.out.println();
sweepLinear(1.5, 2.5, 10);
}
private static void doSomethingWithValue(double value) {
@blubberdiblub
blubberdiblub / foobar.s
Created February 14, 2018 14:35
((struct dirent *)d)->d_name handling in a boolean context
# foobar.c:13: result = (d && d->d_name);
cmpq $0, -24(%rbp) #, d
je .L2 #,
# foobar.c:13: result = (d && d->d_name);
movq -24(%rbp), %rax # d, tmp91
addq $19, %rax #, _1
testq %rax, %rax # _1
je .L2 #,
# foobar.c:13: result = (d && d->d_name);
movl $1, %eax #, iftmp.0_2
require 'log4r'
module VagrantPlugins
module ProviderLibvirt
module Action
class CreateDomain
include VagrantPlugins::ProviderLibvirt::Util::ErbTemplate
def initialize(app, _env)
@logger = Log4r::Logger.new('vagrant_libvirt::action::create_domain')