Skip to content

Instantly share code, notes, and snippets.

@neontorrent
neontorrent / find_missing.sh
Last active June 16, 2023 18:41
Find missing records in A.txt, but not in reference set B.txt
awk 'NR==FNR{a[$0]=1;next}!a[$0]' B A
# or better memory usage:
awk 'NR==FNR{a[$0];next} !($0 in a)' B A
grep -Fvx -f B.txt A.txt
@neontorrent
neontorrent / gist:8bc2c8d8c7a903f76d1d37df477b03fb
Created November 11, 2022 14:36
MacOS URL Handler config
inside:
~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist
@neontorrent
neontorrent / openCwd.sh
Created August 8, 2022 00:12
Open script directory
EXECFILE="$(readlink "$0" || echo "$0")"
EXECPATH="$( cd -- "$(dirname "$EXECFILE")" >/dev/null 2>&1 ; pwd -P )"
cd "$EXECPATH"
In /etc/ssh/sshd_config
IPQoS cs0 cs0
In /etc/fstab
UUID=XXXX /media/pi/Data auto rw,user,auto 0 0
```
sudo setfacl -b /media/pi
#!/bin/sh
# Pump
sudo pmset -a disablesleep 1
sudo pmset -a sleep 0
caffeinate -di
#Sleep
kill `ps -ef | grep caffeinate | grep -v grep | awk '{print $3}'`
sudo pmset -a disablesleep 0
@neontorrent
neontorrent / permutations.scala
Last active February 7, 2022 05:24
permutations
def permutationRecursion(a: List[Int]) = {
import scala.collection.mutable
val results = mutable.ListBuffer[List[Int]]()
def p(curr: List[Int], remaining: List[Int]): Unit = {
if (remaining.isEmpty) {
results += curr
}
else {
for (i <- remaining) {
@neontorrent
neontorrent / ffmpegs.sh
Created September 23, 2021 04:23
ffmpeg
ffmpeg -i input.mp4 -vf mpdecimate,setpts=N/FRAME_RATE/TB out.mp4
@neontorrent
neontorrent / ChangeDisplaySettings.ps1
Last active July 25, 2021 23:14
ChangeDisplaySettings in C# and Powershell, pass byte array as struct pointer
# Version 1. Unsafe C Style
$cp = [System.CodeDom.Compiler.CompilerParameters]::new()
$cp.CompilerOptions = '/unsafe'
$Display = Add-Type -TypeDefinition @'
using System;
using System.Runtime.InteropServices;
public unsafe class Display
{
[DllImport("User32.dll")]
public static extern bool EnumDisplaySettings(
SortedMap.iterableFactory should be Seq instead of Iterable
Add implicits for IterableFactory objects
MapView.values is not lazy
Monoid
empty
concat
append
Functor
map: (a -> b) -> f a -> f b
Monad
unit