Skip to content

Instantly share code, notes, and snippets.


Karl Karlheinzniebuhr

View GitHub Profile
Karlheinzniebuhr / gist:0e996d986ae99f7feb13f7af5b9eb3af
Last active March 31, 2022 05:06
Convert Windows Path to Windows Subsystem for Linux Path with AutoHotKey
View gist:0e996d986ae99f7feb13f7af5b9eb3af
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
^+F1:: ; Ctrl+Shift+F1 (/)
;Empty the Clipboard.
Clipboard =
;Copy the select text to the Clipboard.
Karlheinzniebuhr / data.table-joins.R
Created July 19, 2020 21:51 — forked from nacnudus/data.table-joins.R
How to do joins with data.table
View data.table-joins.R
DT <- data.table(x=rep(c("b","a","c"),each=3), y=c(1,3,6), v=1:9)
X <- data.table(x=c("c","b"), v=8:7, foo=c(4,2))
# [1] "x" "y" "v"
Karlheinzniebuhr / Grep IPs with open ports.txt
Created September 14, 2018 13:13
Grep all IPs with open ports from nmap output txt
View Grep IPs with open ports.txt
cat nmap_scan.txt | grep -B4 open | egrep -o "([0-9]{1,3}\.){3}[0-9]{1,3}"
View gradient descent
Given the starting point of any `x` gradient descent
should be able to find the minimum value of x for the
cost function `f` defined below.
import random
def f(x):
Quadratic function.
Karlheinzniebuhr /
Created June 8, 2017 13:28
Linear regression with gradient descent
# How to Do Linear Regression using Gradient Descent
# import Numpy, THE matrix multiplication library for python
from numpy import *
# minimize the "sum of squared errors". This is how we calculate and correct our error
def compute_error_for_line_given_points(b, m, points):
totalError = 0
for i in range(0, len(points)):
x = points[i, 0]
View Keep Column Sorted in Google
* This Google Sheets script keeps data in the specified column sorted any time
* the data changes.
* After much research, there wasn't an easy way to automatically keep a column
* sorted in Google Sheets, and creating a second sheet to act as a "view" to
* my primary one in order to achieve that was not an option. Instead, I
* created a script that watches for when a cell is edited and triggers
* an auto sort.
import random
text_file = open("randomwordlist.txt", "w")
for i in range(100000000):
text_file.write(str(random.randint(1, 1000000))+"\n")