Skip to content

Instantly share code, notes, and snippets.

@rockdaboot
rockdaboot / Main.java
Created December 3, 2023 17:35
Carthesian Product of N lists without allocations using lambda (forEach)
import java.util.List;
import java.util.function.Consumer;
public class Main {
public static void main(String[] args) {
final List<Integer> l1 = List.of(1, 2, 3, 4, 5);
final List<Double> l2 = List.of(1.1, 2.2, 3.3, 4.4, 5.5);
final List<String> l3 = List.of("a", "b", "c", "d", "e");
CarthesianProduct prod = new CarthesianProduct(l1, l2, l3);
@rockdaboot
rockdaboot / BuildServo_output.log
Created April 25, 2018 19:03
Building servo/servo on Ryzen 1700
tim@ryzen:~$ cd src/servo/
tim@ryzen:~/src/servo$ time ./mach build --dev
info: syncing channel updates for 'nightly-2018-04-15-x86_64-unknown-linux-gnu'
info: latest update on 2018-04-15, rust version 1.27.0-nightly (bd40cbbe1 2018-04-14)
info: downloading component 'rustc'
73.1 MiB / 73.1 MiB (100 %) 31.5 MiB/s ETA: 0 s
info: downloading component 'rust-std'
57.6 MiB / 57.6 MiB (100 %) 34.7 MiB/s ETA: 0 s
info: downloading component 'cargo'
info: downloading component 'rust-docs'
@rockdaboot
rockdaboot / csv2json.py
Created February 20, 2018 12:01
Convert CSV to JSON in two lines of code
import sys
import csv
import json
if __name__=="__main__":
reader = csv.DictReader(sys.stdin)
sys.stdout.write(json.dumps([r for r in reader], sort_keys=False, indent=4, separators=(',', ': ')))
@rockdaboot
rockdaboot / funcptr.c
Last active May 3, 2016 10:52
Iterate through array to make calculations using function pointers
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#define N_ELEMENTS(array) (sizeof(array)/sizeof(*array))
#define APPLY_FORMULA(result, array, func)\
if (N_ELEMENTS(array)) {\
result = array[0];\
for (int8_t i = 1; i < N_ELEMENTS(array); i++)\
result = func(result, array[i]);\