Skip to content

Instantly share code, notes, and snippets.

View mhansen's full-sized avatar
🏠
Trying

Mark Hansen mhansen

🏠
Trying
View GitHub Profile
@mhansen
mhansen / angles.js
Created May 7, 2018 11:36
Calculate whether a difference in angle is clockwise or anticlockwise.
function isClockwise(from, to) {
let diff = normalize(from) - normalize(to);
return normalize(diff) > 180;
}
// Returns angle normalized to between [0, 360).
function normalize(angle) {
while (angle < 0) {
angle += 360;
}
@mhansen
mhansen / keepassx_to_1password.py
Last active October 27, 2017 09:42
Converts from KeepassX exported CSV to 1Password CSV
import pandas
f = pandas.read_csv("keepass_export.csv")
f = f[f["Group"] != "Root/Recycle Bin"]
f2 = pandas.DataFrame()
f2["title"] = f["Title"]
f2["website"] = f["URL"]
f2["username"] = f["Username"]
f2["password"] = f["Password"]
f2["notes"] = f["Notes"]
@mhansen
mhansen / s.c
Created December 4, 2012 13:11
Three sorting algorithms, in C
#include <stdio.h>
#include <string.h>
void swap(char* a, char* b) {
char t = *a;
*a = *b;
*b = t;
}
void bubblesort(char* s, int n) {
import pygame
# Game variables
my_dudes_x_position = 300
bullets = []
window = pygame.display.set_mode((640, 480))
clock = pygame.time.Clock()
def clear_the_screen():
<Point><coordinates>176.0837184,-38.7152427</coordinates></Point> 8 <h1>TWO MILE BAY</h1><h2>Broadcasts</h2><ul><li>tx: MOBILE<br>150.6875<br>SELF LOADER LOGGING</li><li>tx: MOBILE<br>153.55625<br>SELF LOADER LOGGING</li><li>tx: MOBILE<br>150.8375<br>SELF LOADER LOGGING</li><li>tx: MOBILE<br>150.8625<br>SELF LOADER LOGGING</li><li>tx: MOBILE<br>153.53125<br>SELF LOADER LOGGING</li></ul>
import ij.ImagePlus;
import ij.plugin.filter.PlugInFilter;
import ij.process.ImageProcessor;
public class My_Inverter implements PlugInFilter {
public int setup(String arg, ImagePlus im) {
return DOES_8G; // this plugin only works on 8-bit grayscale images
}
public void run(ImageProcessor ip) {
{
"album": {
"#text": "The System is a Vampire",
"mbid": ""
},
"artist": {
"#text": "Shapeshifter",
"mbid": "40d1d78f-6b66-4b14-b8c8-f13786a8cf4f"
},
"date": {
@mhansen
mhansen / hackerz
Created April 4, 2011 08:50
I left an SSH honeypot running on my AWS server for a few days. These are the computers that tried to connect, presumably to try and dictionary attack me:
Connection from 130.217.220.68 port 22 [tcp/ssh] accepted
Connection from 93.155.247.169 port 22 [tcp/ssh] accepted
Connection from 69.14.182.219 port 22 [tcp/ssh] accepted
Connection from 69.14.182.219 port 22 [tcp/ssh] accepted
Connection from 85.217.190.69 port 22 [tcp/ssh] accepted
Connection from 85.217.190.69 port 22 [tcp/ssh] accepted
Connection from 174.36.47.98 port 22 [tcp/ssh] accepted
Connection from 12.234.201.132 port 22 [tcp/ssh] accepted
Connection from 89.16.174.125 port 22 [tcp/ssh] accepted
Connection from 88.191.138.141 port 22 [tcp/ssh] accepted
#!/usr/bin/env ruby
#
# This file, gist, is generated code.
# Please DO NOT EDIT or send patches for it.
#
# Please take a look at the source from
# http://github.com/defunkt/gist
# and submit patches against the individual files
# that build gist.
#
#!/usr/bin/env ruby
#
# This file, gist, is generated code.
# Please DO NOT EDIT or send patches for it.
#
# Please take a look at the source from
# http://github.com/defunkt/gist
# and submit patches against the individual files
# that build gist.
#