Skip to content

Instantly share code, notes, and snippets.

mendhak /
Created Nov 24, 2018
Calculate checksum from the data part of an NMEA sentence
import sys
import operator
# Given the data part of an NMEA sentence (Remove the $, remove the * onwards, keep the last comma)
# calculates the checksum
def checksum_calculate(nmeadata):
csum = 0
for c in nmeadata:
csum ^= ord(c)
mendhak /
Created Aug 16, 2018
Terraform - API Gateway with greedy path (proxy+) calling httpbin. Also includes deployment
resource "aws_api_gateway_rest_api" "MyDemoAPI" {
name = "MyDemoAPI"
description = "This is my API for demonstration purposes"
resource "aws_api_gateway_resource" "MyDemoResource" {
rest_api_id = "${}"
parent_id = "${aws_api_gateway_rest_api.MyDemoAPI.root_resource_id}"
path_part = "{proxy+}"
mendhak / initialize-raw-disks.ps1
Created Oct 27, 2017
Initialize raw disks in Windows, partition, format and assign drive letters
View initialize-raw-disks.ps1
$rawdisks = gwmi win32_diskdrive | where {$_.partitions -eq 0}
foreach ($r in $rawdisks)
$available=ls function:[d-z]: -n | ?{ !(test-path $_) } | SELECT -First 1
$diskIndex = $r.Index
Write-Host "Initializing Disk $diskIndex as $available. This will take a while."
(echo "list disk
select disk $diskIndex
online disk
attributes disk clear readonly
mendhak /
Created Aug 25, 2017 — forked from bradmontgomery/
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else. Also prints POST body
#!/usr/bin/env python
Very simple HTTP server in python.
./ [<port>]
Send a GET request::
curl http://localhost
mendhak /
Last active Mar 25, 2020 — forked from duebbert/
Script to help Bash on Ubuntu on Windows use KeeAgent's TCP socket file - so ssh can use KeePass installed on Windows 10
msysGit to Unix socket proxy
This small script is intended to help use msysGit sockets with the new Windows Linux Subsystem (aka Bash for Windows).
It was specifically designed to pass SSH keys from the KeeAgent module of KeePass secret management application to the
ssh utility running in the WSL (it only works with Linux sockets). However, my guess is that it will have uses for other
mendhak /
Last active Oct 31, 2020
Update a pull request by pushing to another user's forked repository

Add the other user as a remote

#Using https
git remote add otheruser
# Or - Using SSH
git remote add otheruser


git fetch otheruser
mendhak /
Last active May 30, 2017
Reliable methods of creating SSH tunnels for TCP forwarding
#SSH feature - control sockets
ssh -4 -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa -M -S my-ctrl-socket -fnNT -L dev@middleserver.internal
#Get PID - you'll have to parse this
ssh -S my-ctrl-socket -O check dev@middleserver.internal
ssh -S my-ctrl-socket -O exit dev@middleserver.internal
mendhak /
Last active Mar 30, 2019 — forked from marteinn/
ScrollView with a OnBottomReachedListener for Android
package se.marteinn.ui;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ScrollView;
* Triggers a event when scrolling reaches bottom.

Keybase proof

I hereby claim:

  • I am mendhak on github.
  • I am mendhak ( on keybase.
  • I have a public key whose fingerprint is 6989 CF77 4903 69CF FDCB CD89 95E7 D75C 76CB E9A9

To claim this, I am signing this object:

mendhak /
Created Mar 23, 2014
A script to download and concatenate AWS ELB Access logs
import os
import pytz
import sys
import datetime
import dateutil.parser
import boto
downloadFolder = "downloads"
if len(sys.argv) > 1:
You can’t perform that action at this time.