Skip to content

Instantly share code, notes, and snippets.

View hrj's full-sized avatar
πŸ”­
observing

hrj hrj

πŸ”­
observing
View GitHub Profile
@hrj
hrj / resources.md
Created August 26, 2015 11:27
Programming for kids

Languages designed for learning

@hrj
hrj / symbols.md
Last active October 8, 2015 18:24
flif symbols

Static data

nm --size-sort -S -C -r flif | grep "\<[Rr]\>" 
size               name
----------------------------
0000000000002002 R log4k
0000000000000800 R crc32k_tab
@hrj
hrj / huffman.scala
Created October 10, 2015 20:03
huffman estimation
// Huffman estimation given symbol counts
val symbolCountsIn = Array(57728,32858,49395,15703,26381,4506,5797,1129,958,392,164,278,61,206,30,193,19,172,9,150,4,91,4,91,1,71,4,44,2,29,1,28,1,32,0,15,0,8,0,12,0,11,0,15,0,6,0,4,0,0,0,2,0,1,0,2)
case class Symbol(count:Int, idx: Int)
sealed trait TreeNode {
def value:Int
}
@hrj
hrj / list.md
Created November 24, 2015 03:52
gcc optimisations that remain disabled in -O3

list

-fbranch-probabilities
-fbranch-target-load-optimize
-fbranch-target-load-optimize2
-fbtr-bb-exclusive
-fconserve-stack
-fcx-fortran-rules
-fcx-limited-range
-fdata-sections
@hrj
hrj / Compute.java
Last active January 26, 2016 19:14
Benchmarks for doppio
public class Compute {
public static void main(String args[]) {
final long start = System.currentTimeMillis();
final long ans = rep(8000);
final long end = System.currentTimeMillis();
System.out.println(ans);
System.out.println("Time taken (ms): " + (end - start));
}
public static long rep(long n) {
@hrj
hrj / notes.md
Last active July 7, 2016 09:42
Notes on setting up synapse federation behind a reverse proxy
  • The certificate file used by the reverse proxy should be exactly the same as the one used by synapse. If you use the concatenated certificate chain on the reverse-proxy, it should be the same in synapse.
  • You need to generate and give Diffie Hellman parameters to the reverse proxy. This ensures that the cipher suites required by matrix are available in the reverse proxy.
  • Matrix servers use the 8448 port to talk with each other by default.
  • Either you need to expose this port (8448) in the firewall, or you need to add a SRV record in the DNS pointing to port 443 (https port).
  • This tool can help diagnose problems.
@hrj
hrj / dual_axis_three_ldr_sun_tracker.ino
Last active October 25, 2016 14:22 — forked from chetankothari/dual_axis_three_ldr_sun_tracker.ino
Dual axis sun tracker using three LDR and Arduino Uno
// Authored by the "HeadBanger" team at SHD India.
// Shared under MIT License
#include <Servo.h>
#define NUM_PINS 3
int sensorPins[NUM_PINS] = {A0, A1, A2};
int sensorValues[NUM_PINS] = {0, 0, 0};
@hrj
hrj / compare.scala
Last active November 4, 2016 19:19
DSSIM comparison for chroma lossiness PR to FLIF
import scala.sys.process._
import java.nio.file.Files
import java.nio.file.Paths
val flif1 = args(0)
val flif2 = args(1)
val imgBase = args(2)
val images = Seq("ls", "-1", imgBase).lineStream.filter(_.endsWith(".png")).toList
@hrj
hrj / renders-pyra.csv
Created November 7, 2016 18:16
Benchmark results for FLIF lossy chroma patch
We can make this file beautiful and searchable if this error is corrected: It looks like row 7 should actually have 8 columns, instead of 1 in line 6.
BeigePyraBack.png.2624e1242871643a4cc9e0a3edc015d8.png.d80576b60a14f708468a147bc1ced015.png, 0, 300899, 13026, 12785, 0.001651469967328012, 0.0017180199502035975, 0.00007
BeigePyraBack.png.2624e1242871643a4cc9e0a3edc015d8.png.d80576b60a14f708468a147bc1ced015.png, 20, 300899, 16249, 15912, 0.0014276399742811918, 0.0014876299537718296, 0.00006
BeigePyraBack.png.2624e1242871643a4cc9e0a3edc015d8.png.d80576b60a14f708468a147bc1ced015.png, 40, 300899, 22041, 21626, 0.0011894300114363432, 0.0012190600391477346, 0.00003
BeigePyraBack.png.2624e1242871643a4cc9e0a3edc015d8.png.d80576b60a14f708468a147bc1ced015.png, 60, 300899, 27274, 26511, 0.0010326399933546782, 0.0010415699798613787, 0.00001
BeigePyraBack.png.2624e1242871643a4cc9e0a3edc015d8.png.d80576b60a14f708468a147bc1ced015.png, 80, 300899, 81539, 79640, 3.197799960616976E-4, 3.377299872227013E-4, 0.00002
BeigePyraBase.png.e82c2a43169481d4417c2005616bc48f.png, 0, 366612, 25649, 24886, 0.002077220007777214, 0.0022704401053488255, 0.00019
BeigePyraBase.png.e82c2a43169
@hrj
hrj / dumpflif.c
Created May 28, 2017 14:26
dumpflif
/*
Example application of FLIF decoder using libflif_dec
Copyright (C) 2017 Harshad RJ
Based on the viewflif code.
License: Creative Commons CC0 1.0 Universal (Public Domain)
https://creativecommons.org/publicdomain/zero/1.0/legalcode
*/