Skip to content

Instantly share code, notes, and snippets.

View jonasmalacofilho's full-sized avatar

Jonas Malaco jonasmalacofilho

View GitHub Profile
@waneck
waneck / Repl.hx
Last active September 13, 2020 14:04
Very simple Haxe REPL
/*
Copyright (c) 2014 Cauê Waneck
All rights reserved.
Redistribution and use in source and binary forms are permitted
provided that the above copyright notice and this paragraph are
duplicated in all such forms and that any documentation,
advertising materials, and other materials related to such
distribution and use acknowledge that the software was developed
by the <organization>. The name of the
@back2dos
back2dos / EventDispatcher.hx
Last active July 9, 2020 03:20
Typesafe version of `flash.events.EventDispatcher` to make the Flash API suck a little less. Would also work for `js.html.EventTarget`.
package flash.events;
extern class EventDispatcher implements IEventDispatcher {
function new(?target:IEventDispatcher) : Void;
function addEventListener<T:Event>(type:EventType<T>, listener: T->Void, useCapture:Bool = false, priority:Int = 0, useWeakReference:Bool = false):Void;
function dispatchEvent(event:Event):Bool;
function hasEventListener(type:String):Bool;
function removeEventListener<T:Event>(type:EventType<T>, listener: T->Void, useCapture:Bool = false):Void;
function toString():String;
function willTrigger(type:String):Bool;
@jasononeil
jasononeil / Metric.hx
Last active November 10, 2016 11:16
Demonstration of using Haxe abstracts to take care of explicit conversions between different units of measurement, with no performance overhead.
class Metric {
static function main() {
var coinRadius:Millimeters = 12;
var myHeight:Centimeters = 180;
var raceLength:Meters = 200;
var commuteDistance:Kilometers = 23;
diff( coinRadius, myHeight ); // 1.788 meters
diff( raceLength, commuteDistance ); // 22800 meters
sum( commuteDistance, coinRadius ); // 23000.012 meters
@imjasonh
imjasonh / markdown.css
Last active May 24, 2024 22:56
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@Andrei-Pozolotin
Andrei-Pozolotin / activate.sh
Last active November 7, 2021 07:33
ubuntu 14.04 cryptsetup luks suspend/resume root partition
#!/bin/bash
#
# ubuntu 14.04 cryptsetup luks suspend/resume root partition sleep activation
#
source=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) # install script folder
target=/run/pm-crypto # chroot environment folder
bind_list="/dev /proc /sys /run" # special system mounts
@m-ou-se
m-ou-se / replace-debian-with-arch.txt
Last active October 22, 2023 12:16
Instructions to replace a live Debian installation with Arch
# Download latest archlinux bootstrap package, see https://www.archlinux.org/download/
wget 'ftp://ftp.nluug.nl/pub/os/Linux/distr/archlinux/iso/latest/archlinux-bootstrap-*-x86_64.tar.gz'
# Make sure you'll have enough entropy for pacman-key later.
apt-get install haveged
# Install the arch bootstrap image in a tmpfs.
mount -t tmpfs none /mnt
cd /mnt
tar xvf ~/archlinux-bootstrap-*-x86_64.tar.gz --strip-components=1
@rygorous
rygorous / gist:e0f055bfb74e3d5f0af20690759de5a7
Created May 8, 2016 06:54
A bit of background on compilers exploiting signed overflow
Why do compilers even bother with exploiting undefinedness signed overflow? And what are those
mysterious cases where it helps?
A lot of people (myself included) are against transforms that aggressively exploit undefined behavior, but
I think it's useful to know what compiler writers are accomplishing by this.
TL;DR: C doesn't work very well if int!=register width, but (for backwards compat) int is 32-bit on all
major 64-bit targets, and this causes quite hairy problems for code generation and optimization in some
fairly common cases. The signed overflow UB exploitation is an attempt to work around this.
@TheUbuntuGuy
TheUbuntuGuy / fuckuanova.py
Created April 23, 2017 20:17
Decode Anova Precision Cooker WiFi Packets
#!/usr/bin/python3
import math
f = open("rawdump.txt", "r")
for l in f.readlines():
p = 0
chars = []
chksum = 0
@krpors
krpors / cycle.sh
Last active May 30, 2020 08:30
inotifywait for cargo
#!/usr/bin/env bash
# Clear the screen, run the initial command in the background immediately,
# and then get the PID. We need that to kill it later (if the program is a
# server/daemon or the like).
${*} &
pid=$!
# Now run inotifywait and only act on certain events, recursively.
# Kill the previous PID (if applicable). Will output an error if the