Skip to content

Instantly share code, notes, and snippets.

View iximeow's full-sized avatar
🐟
you can tune a piano but you can't tuna fish

iximeow iximeow

🐟
you can tune a piano but you can't tuna fish
View GitHub Profile
@iximeow
iximeow / welp.scala
Created October 14, 2015 21:36
smells like a scalac bug?
object X extends App {
def uniq[T](x: T) =
new {
type Q = this.type
def e(x: Q) = ()
def q2(x: Q): String = "hello!"
}
val x = uniq(1)
val y = uniq(1)
@iximeow
iximeow / test.sh
Created November 9, 2015 06:00
bash the crypto breaking BEAST
#! /bin/bash
#
# wondering how long bash would take to break https://github.com/Dirktheman/rsa-codeigniter-library/blob/master/application/libaries/Rsa.php#L33-L87
# answer: not long.
#
# > time ./test.sh
# #primes found:
# p: 9473, q: 9479
#
# real 0m2.832s
@iximeow
iximeow / CompileChecks.scala
Created November 14, 2015 08:44
macros to test for does-it-compile-ness
import scala.reflect.macros.{Context, TypecheckException}
import scala.reflect.runtime.universe._
import scala.language.experimental.macros
import scala.util.{Success, Failure}
import java.util.regex.Pattern
/*
* Heavily inspired by ShouldNotTypecheck (from slick) and
@iximeow
iximeow / build.sbt
Last active November 16, 2015 22:38
scalac-checked restricting recursion
name := "sbt_playground"
scalaVersion := "2.11.7"
scalaSource in Compile := baseDirectory.value / "src"
scalaSource in Test := baseDirectory.value / "test"
libraryDependencies ++= Seq(
"com.chuusai" %% "shapeless" % "2.2.5"
@iximeow
iximeow / pf.asm
Created March 22, 2017 22:21
x86 parity flag
; nasm -f macho -o pf.o
; ld pf.o
; ./a.out
;
; this probably works on linuxes too, i think exit and write should be the same.
;
; should produce:
; tears (2)
; 00000246 <-- eax = 0, xor by 0
; 00000206 <-- xor ax, 0x0100
@iximeow
iximeow / bad_csharp.cs
Last active September 7, 2017 10:28
i challenge you to explain why this: 1: prints "What was null???" 2: throws an NRE 3: DOES NOT THROW IF YOU REMOVE ANY LINE IN mangler()
using System.Runtime.InteropServices;
using System.Reflection;
using System;
public class lol {
internal delegate void lolwut();
static Delegate d;
static MethodInfo info;
static unsafe byte* rawptr;
public static void Main(System.String[] args) {
@iximeow
iximeow / bootloader.asm
Created December 12, 2017 06:41
x86 totally supports read/write to 0
; assemble like `nasm bootloader.asm` (will produce a flat binary output by default)
; run like `qemu-system-x86_64 bootloader`
[BITS 16]
[ORG 7c00h]
init:
mov cx, 0xB800
mov gs, cx
call clr_vga
mov si, HELLO
@iximeow
iximeow / segment_heccery.asm
Created December 29, 2019 11:20
what does Sz bit do in protected mode
; build and run: `nasm segment_heccery.asm -f bin -o img.bin && qemu-system-x86_64 img.bin -s -S`
[BITS 16]
[ORG 7c00h]
init:
cli
lgdt [gdtr]
mov eax, cr0
or al, 1
@iximeow
iximeow / the_good_rust.rs
Created July 1, 2020 19:23
monkeypatching in rust
trait Person {
fn greeting(&self) -> StateOfMind;
fn name(&self) -> &'static str;
}
struct Ixi { }
struct Katie { }
#[derive(Debug)]
enum StateOfMind {
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/ucontext.h>
#include <stdint.h>
void interpret(char op) {
printf("interpreting %02x\n", op);
}