Skip to content

Instantly share code, notes, and snippets.

View rajanski's full-sized avatar

rajanski

View GitHub Profile
@tahir-hassan
tahir-hassan / GetCircleFromPoints.ps1
Created July 18, 2021 17:01
PowerShell code to get a circle from three points on an arc.
class Point {
[double]$X;
[double]$Y;
Point([double]$x, [double]$y) {
$this.X = $x;
$this.Y = $y;
}
[Point]Add([double]$xDelta, [double]$yDelta) {
@jodiecunningham
jodiecunningham / idle.sh
Created August 9, 2015 15:13
Shut down idle AWS plex instance
#!/bin/bash
#set -x
#DEBUG=echo
# Runs via cron to shut down the instance if it's not in use for 5 minutes
# Starts checks after it's been up more than 500secs
# Won't kick you out if you're ssh'ed in and it's idle.
# crontab -l|grep idle
# */6 * * * * /root/bin/idle.sh >/dev/null 2>&1
until $(awk '$1>500{exit 1}' /proc/uptime)
@jodiecunningham
jodiecunningham / awscheck.sh
Created August 9, 2015 15:04
AWS Startup on-demand script
#!/bin/sh
# Install the AWS CLI, set up an IAM user for the instance(s) you want to control.
# Pull the AWS keys for the IAM user and run aws configure to add them.
# I run this on Sophos UTM and have Sophos run a reverse proxy from the \
# $ROUTERIP:32400 to $PLEXHOST:32400
# set -x
# started with screen -Sdm a '/root/bin/awscheck.sh'een -Sdm a '/root/bin/awscheck.sh'screen -Sdm a '/root/bin/awscheck.sh'screen -Sdm a '/root/bin/awscheck.sh'n -Sdm a '/root/bin/awscheck.sh'
PLEXHOST=dokie.duckdns.org
WANIF=eth2
@iandanforth
iandanforth / kmeansExample.py
Last active May 13, 2024 14:00
A pure python implementation of K-Means clustering. Optional cluster visualization using plot.ly.
#############################################################################
# Full Imports
from __future__ import division
import math
import random
"""
This is a pure Python implementation of the K-means Clustering algorithmn. The
original can be found here:
@aflaxman
aflaxman / gist:287370
Created January 26, 2010 23:34
networkx-osm import open street map data as a networkx graph
"""
Read graphs in Open Street Maps osm format
Based on osm.py from brianw's osmgeocode
http://github.com/brianw/osmgeocode, which is based on osm.py from
comes from Graphserver:
http://github.com/bmander/graphserver/tree/master and is copyright (c)
2007, Brandon Martin-Anderson under the BSD License
"""