Skip to content

Instantly share code, notes, and snippets.

View tazjin's full-sized avatar
🥝
computers

tazjin

🥝
computers
View GitHub Profile
@tazjin
tazjin / type.rs
Created October 22, 2017 22:02
Rust Postgres enum types.
#[derive(ToSql, FromSql, Debug, PartialEq, Serialize, Deserialize)]
#[postgres(name = "process_status")]
pub enum Status {
#[postgres(name = "approved")]
APPROVED,
#[postgres(name = "rejected")]
REJECTED,
#[postgres(name = "pending")]
@tazjin
tazjin / real-world-go-bugs.md
Last active October 6, 2017 09:35
Real-world Go application bugs

This is a list of bugs that exist(ed) in real-world Go applications that are mostly rooted in the language being unsafe. I update this list whenever I find one of those.

Last update: 2017-10-06

For the unknowing: Go is a weakly typed, primitive language that you can think of as "C with a garbage collector". Here is [a curated list][] of lists of reasons for why Go is a bad language.

Now for the bugs:

"meep!"
@tazjin
tazjin / jacksonTest.kt
Created August 17, 2017 15:50
Jackson roundtrip test
private inline fun <reified T> T.testJacksonRoundtrip() {
val json = jacksonObjectMapper().writeValueAsString(this)
val result: T = jacksonObjectMapper().readValue(json, T::class.java)
assertEquals(
"Roundtrip-serialisation of ${T::class.java.simpleName} should result in equal value",
this,
result
)
}
#!/usr/bin/perl -CA
use open qw/:std :utf8/;
use POSIX;
use Encode;
#binmode(STDOUT, ":utf8");
#use encoding 'utf8';
if (not defined $ARGV[0]) {
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <zlib.h>
#include <ctype.h>
3 vincent@stallo ~ % hiyoga list-bookings :(
Booked classes:
Wednesday 06:00-08:00 Ashtanga Mysore Basia Lipska Larsen (confirmed)
Wednesday 19:00-20:30 Restorative Elise Jansen (confirmed)
Thursday 06:00-08:00 Ashtanga Mysore Basia Lipska Larsen (confirmed)
Thursday 20:15-21:30 Hatha Yoga Kamaldeep Kaur Banga (confirmed)
Saturday 07:30-09:30 Ashtanga Mysore Basia Lipska Larsen (confirmed)
Sunday 11:30-12:45 Halv Ashtanga Ledet Hanne Vestre (confirmed)
@tazjin
tazjin / $.java
Last active October 20, 2016 21:05
Don't do this
package com.spookyjava;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Supplier;
public class $<T> {
@FunctionalInterface
interface TriConsumer<A,B,C> {
void consume(A a, B b, C c);
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
public class $<T> {
final private Function<T, T> f;
public static <T> $<T> $() {
return new $(Function.identity());
}
import java.util.function.Consumer;
import java.util.function.Function;
public class $<T> {
final private Function<T, T> f;
public $(Consumer<T> c) {
this.f = apply(c);
}