Skip to content

Instantly share code, notes, and snippets.

View W4RH4WK's full-sized avatar
🔱
A demon, killing demons

Alex Hirsch W4RH4WK

🔱
A demon, killing demons
View GitHub Profile
@W4RH4WK
W4RH4WK / Main.java
Created April 30, 2013 20:58
Java Finite State Machine
public class Main {
public static void main(String[] args) {
SensorState s = SensorState.One;
s = s.run();
s = s.run();
}
}
@W4RH4WK
W4RH4WK / signalHandler.c
Last active December 17, 2015 02:29
Signal Handler example
#include <signal.h>
#include <string.h>
void signalHandler(int sigNum) {
if (sigNum == SIGUSR1) {
// do stuff
} else if (sigNum == SIGUSR2) {
// do other stuff
}
}
@W4RH4WK
W4RH4WK / bit_case.scad
Last active August 29, 2015 13:56
3D printed case for bits
module hexagon(size, height) {
boxWidth = size/1.75;
for (r = [-60, 0, 60])
rotate([0,0,r])
cube([boxWidth, size, height], true);
}
module combs(x_count, y_count, hex_size, wall_size, height) {
function x_pos(x, y) = (hex_size + wall_size) * x + ((y % 2 == 0) ? 0 : (hex_size + wall_size) / 2);
function y_pos(x, y) = (hex_size) * y;
@W4RH4WK
W4RH4WK / github_repos
Last active February 27, 2016 15:18
Github Backup
#!/usr/bin/env python
import requests
token = 'INSERT TOKEN HERE'
def list_repos():
repos = requests.get(
@W4RH4WK
W4RH4WK / client.go
Created November 20, 2014 10:44
Challenge Response in Go
package main
import (
"bufio"
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
"log"
"net"
"strings"
@W4RH4WK
W4RH4WK / hijack.c
Created November 22, 2014 22:27
Basic Idea of Function Hijacking
#include <stdio.h>
#include <stdint.h>
#include <sys/mman.h>
void func1(void) {
printf("func1\n");
}
void func2(void) {
printf("func2\n");
@W4RH4WK
W4RH4WK / insert.scad
Last active August 29, 2015 14:10
parameterized OpenSCAD file for small containers
module insert(xcount, ycount, hspacer=0, vspacer=0, feet=true, side=47.55,
height=23, wall=1, cornerradius=4) {
x_space = side * xcount + 2 * (xcount - 1);
y_space = side * ycount + 2 * (ycount - 1);
x_corner = [
cornerradius,
x_space - cornerradius
syn keyword asmRegRax %rax rax
syn keyword asmRegEax %eax eax
syn keyword asmRegAx %ax ax
syn keyword asmRegAh %ah ah
syn keyword asmRegAl %al al
syn keyword asmRegRbx %rbx rbx
syn keyword asmRegEbx %ebx ebx
syn keyword asmRegBx %bx bx
syn keyword asmRegBh %bh bh
syn keyword asmRegBl %bl bl
@W4RH4WK
W4RH4WK / screen_rotate.sh
Created May 19, 2015 09:43
rotate screen every second
#!/bin/bash
while true; do
x=$(date "+%s")
x=$(( $x % 360 ))
pi=`echo "4*a(1)" | bc -l`
xrad=`echo "$x*($pi/180)" | bc -l`
sinx=`echo "s($xrad)" | bc -l`
sinx2=`echo "- s($xrad)" | bc -l`
cosx=`echo "c($xrad)" | bc -l`
#include <iostream>
using namespace std;
class A {
protected:
int count;