Skip to content

Instantly share code, notes, and snippets.

View FauxFaux's full-sized avatar

Chris West FauxFaux

View GitHub Profile
@FauxFaux
FauxFaux / readFileSync_vs_readFile.js
Last active March 19, 2022 04:12 — forked from Kirill89/readFileSync_vs_readFile.js
readFileSync vs readFile benchmark
const fs = require('fs');
const fsp = fs.promises;
const util = require('util');
const readFile = util.promisify(fs.readFile);
fs.writeFileSync('a', 'a');
const attempts = 10000;
@FauxFaux
FauxFaux / pom.xml
Created March 20, 2019 09:09
Maven can't version range ???
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.egg</groupId>
<artifactId>egg</artifactId>
<version>1.0-SNAPSHOT</version>
<name>egg</name>
<dependencies>
@FauxFaux
FauxFaux / 1.green-Yellow.java
Created January 24, 2019 09:31
Java source to .class mapping
// Here's a .java file, named 'Yellow.java'
// Inside a package (and directory) named 'green'
package green;
// Here's a class named 'Blue'
class Blue {
// Here's a method named 'foo' inside 'Blue'
void foo() {
import java.io.FileInputStream;
import java.io.IOException;
public class A {
static long checkHeader(String path) throws IOException {
// can't use try() as there's no way to catch only the initialisation exception?
final FileInputStream fis;
try {
fis = new FileInputStream(path);
} catch (IOException e) {
@FauxFaux
FauxFaux / bad-locking.ts
Created December 18, 2018 10:58
Type system can't save you from missing awaits
/*
% npm install typescript
.. warnings blah blah..
+ typescript@3.2.2
updated 1 package and audited 2 packages in 0.538s
found 0 vulnerabilities
% node_modules/.bin/tsc --lib es2018,dom --target es2018 --strict --noImplicitReturns --noImplicitAny --out hello.js hello.ts
@FauxFaux
FauxFaux / dump-firebird.py
Created November 17, 2018 11:35
Dump a firebird database to json (and never look back)
import fdb
import json
import sys
import decimal
import datetime
def js(val):
if type(val) == int:
return val
if type(val) == str:
@FauxFaux
FauxFaux / before.yaml
Created May 29, 2018 15:35
diagnosing swagger allOf
swagger: '2.0'
info:
version: 1.0.0
title: Example API
description: |
blabla
termsOfService: Copyright TEST eG - 2015
contact:
name: info@example.de
license:
@FauxFaux
FauxFaux / compton-colour.glsl
Created December 27, 2017 01:07
compton compositor compatible code for colour correction
/* compton --backend glx --glx-fshader-win "$(cat ~/compton-colour.glsl)" */
uniform sampler2D tex;
/*mProtanopia*/
//static const half3 blindVisionR = float3( 0.20 , 0.99 , -0.19 );
//static const half3 blindVisionG = float3( 0.16 , 0.79 , 0.04 );
//static const half3 blindVisionB = float3( 0.01 , -0.01 , 1.00 );
/*mDeuteranopia*/
//static const half3 blindVisionR = float3( 0.43 , 0.72 , -0.15 );
//static const half3 blindVisionG = float3( 0.34 , 0.57 , 0.09 );
// gcc -Wall -Wextra -O2 guess.c -lcrypto -o guess
#include <openssl/des.h>
#include <stdint.h>
#include <string.h>
int main() {
DES_cblock key_data;
if (!DES_random_key(&key_data)) {
printf("couldn't generate random key");
@FauxFaux
FauxFaux / dpkg-S.c
Created July 12, 2017 16:41
Is hand-written C faster than Python? Yes, yes it is.
// make CFLAGS=-O2 dpkgs && time ./dpkgs /lib/systemd/systemd
#define _POSIX_C_SOURCE 200809L
#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <dirent.h>
#include <assert.h>
#include <string.h>