Skip to content

Instantly share code, notes, and snippets.

View soypat's full-sized avatar
🎴

Patricio Whittingslow soypat

🎴
View GitHub Profile
@soypat
soypat / sub4section.cls
Created August 18, 2021 20:36
subsubsubsubsection for Latex
%----------------Lo de 4th layer de subsectrion
\titleclass{\subsubsubsection}{straight}[\subsection]
\newcounter{subsubsubsection}[subsubsection]
\renewcommand\thesubsubsubsection{\thesubsubsection.\arabic{subsubsubsection}}
\renewcommand\theparagraph{\thesubsubsubsection.\arabic{paragraph}} % optional; useful if paragraphs are to be numbered
\titleformat{\subsubsubsection}
{\normalfont\normalsize\bfseries}{\thesubsubsubsection}{1em}{}
@soypat
soypat / fastisqrt.go
Created May 23, 2021 19:04
Fast Inverse Root from Quake implemented in Golang
package quake
import "unsafe"
type float = float32
// FastISqrt implements Quake fast inverse square root
func FastISqrt(number float) float {
type long = uint64
const threehalf = 3. / 2.
@soypat
soypat / gomap.go
Created April 16, 2021 15:08
Ping addresses on a network for discovery. Use CIDR addresses, i.e. 192.168.1.0/24 (pings 256 addresses)
package main
import (
"errors"
"fmt"
"net"
"os"
"os/signal"
"strconv"
"sync"
@soypat
soypat / macroni.go
Last active November 5, 2021 02:14
Evaluate bitwise expressions and macros. i.e: 0xa3 &^ 0b001
package main
import (
"fmt"
"os"
"reflect"
"strings"
"github.com/cosmos72/gomacro/fast"
"github.com/spf13/pflag"
@soypat
soypat / sleep.go
Created February 12, 2021 18:02
Cgo usleep vs. pure Go time.Sleep. Run with `go test -bench=.`
package ctest
// #include <time.h>
// void wait(int usec)
// {
// usleep(usec);
// }
import "C"
import "time"
@soypat
soypat / syncAndGo.sh
Created February 7, 2021 13:10
Remote folder sync and Go execution. Ideal for Raspberry Pi
git_dir="software-v2"
project_path="$(git rev-parse --show-toplevel 2> /dev/null)/$git_dir"
[email protected]
if [ $? -eq 0 ]; then
# name of the project folder
project_name=`basename $project_path`
@soypat
soypat / su_bash.md
Last active February 10, 2021 17:05
  • # start comment on line. For examples # shall denote a file or argument of a command to facilitate examples

operators

  • #cmd_output > #file write output of command to file
  • #cmd_output >> #file append output to file
  • #cmd_output | #cmd redirect output to a command's input
  • #cmd1 && #cmd2 runs second command only if first one exited succesfully
  • #cmd & runs command in background
@soypat
soypat / gopher_sitting.svg
Last active October 11, 2020 15:48
Original Artwork by Renée French - traced by Patricio Whittingslow
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@soypat
soypat / settings.json
Created October 8, 2020 23:49
Golang settings for enabling gopls and making delve string print longer
{
"workbench.colorTheme": "Darcula",
"explorer.confirmDelete": false,
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
"files.associations": {
"*.py": "python",
"*.html": "html"
},
"go.formatTool": "goimports",
"go.lintTool": "golangci-lint",
@soypat
soypat / mergeDictionary.py
Created September 19, 2020 23:12
Merge some .dic files into one. I use it for updating texstudio's dictionary between the machines I use.
import os
fs = os.listdir()
wordset = set()
enc = input("Write encoding (default: 'utf-8'. use '1252' for windows files) ")
enc = "utf-8" if enc == "" else enc
for f in fs:
last=f[len(f)-4:len(f)]
if last == ".dic":
YorN = input(f"Do you wish to merge {f}? (y/N)")
if YorN.lower() == "y":