Skip to content

Instantly share code, notes, and snippets.

@CarpeNoctem
CarpeNoctem / php_array_pull.php
Created February 11, 2014 07:49
PHP function I needed, that I thought might be useful for others as well. Like array_pop(), but for a specific array element instead of the very last one.
<?
// Dec 2013 - CarpeNoctem
// Like array_pop(), for a specific array element instead of the very last one.
function pull(&$array,$key)
{
$ret = $array[$key];
unset($array[$key]);
return($ret);
}
@CarpeNoctem
CarpeNoctem / .tmux.conf
Created January 30, 2017 00:56
Simple tmux config file to use ctrl+a instead of ctrl+b
set -g prefix C-a
bind-key C-a last-window
bind-key a send-prefix
@CarpeNoctem
CarpeNoctem / a_how_to_properly_divide_work.py
Last active January 28, 2018 21:37
Much better way to divide work than the way I initially did in port_scanner.py
# This is probably the right way to divide work.
# At least I think it's better than they I had done it previously in port_scanner.py,
# and I'll fix port_scanner.py to use the below method.
# Kudos to this question and answer for the better way to get intersecting points in
# a range for an arbitrary number of sections:
# https://stackoverflow.com/questions/20925175/evenly-distribute-x-values-within-a-given-range#20925282
# I played around a while with that and combined it to the way I distributed work in my Elixir port scanner to eventually
# arrive at the below solution.
def child(host, low, high):
@CarpeNoctem
CarpeNoctem / TodaysVersion.go
Created January 26, 2018 14:30
Dividing work in a go (golang) port scanner
func ScanRangeTwo(min, max, num_threads int) (open_ports []string) {
open_ch := make(chan []string, num_threads)
high := min - 1
for i := 0; i < num_threads; i++ {
low := high + 1
high = min + (i+1)*(max-min)/num_threads
//fmt.Printf("Child #%d should scan %d through %d\n", i+1, low, high)
go CheckRange(open_ch, low, high)
}
for i := 0; i < num_threads; i++ {
@CarpeNoctem
CarpeNoctem / day-01_part-01.exs
Last active December 10, 2018 09:43
Advent of Code 2018
File.read!("advent_input_day1.txt")
|> String.split
|> Enum.map(&String.to_integer/1)
#|> Enum.reduce(&(&1 + &2))
|> Enum.sum
|> IO.puts
@CarpeNoctem
CarpeNoctem / pat_config.json
Last active October 28, 2020 16:42
Get Pat going on Raspberry Pi (4)
{
"mycall": "YourCallsignHere",
"secure_login_password": "YourWinlinkPasswordHere",
"auxiliary_addresses": [],
"locator": "YourGridSquareHere",
"service_codes": [
"PUBLIC"
],
"http_addr": "localhost:8080",
"motd": [
#!/bin/bash
# Installs and configures gpsd and chrony to update the system clock via GPS when network unavailable.
# Thanks to OH8STN & G4WNC https://photobyte.org/raspberry-pi-stretch-gps-dongle-as-a-time-source-with-chrony-timedatectl/
# TODO: Add sanity checks to make sure steps go as planned (e.g. detect GPS actually working, detect NMEA listed in chronyc sources)
read -p 'Please close any other programs using your gps device and then hit Enter to continue.' gogo;
sudo apt -y install gpsd chrony; #gpsd-clients
# Consider auto-detecting with grepping for 'source "/dev/tty.*" added' in dmesg output to make useful not only for IC-705
@CarpeNoctem
CarpeNoctem / serial_to_epaper.ino
Created October 24, 2021 09:13
Text to epaper shield via serial
tba