Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jacobsalmela's full-sized avatar
:octocat:
To all that makes us unique

Jacob Salmela jacobsalmela

:octocat:
To all that makes us unique
View GitHub Profile
@jacobsalmela
jacobsalmela / set-wallpaper-universal.py
Last active August 29, 2015 14:03 — forked from gregneagle/gist:6957826
(OS X) Universal script for setting the wallpaper. Works on 10.6-10.9
#!/usr/bin/python
# Universal wallpaper script for 10.6 and up
from AppKit import NSWorkspace, NSScreen
from Foundation import NSURL
from platform import mac_ver
from subprocess import call
from os import system
# Set path here for 10.9
picture_path = "/Library/Desktop Pictures/Custom.jpg"
@jacobsalmela
jacobsalmela / unshare_all_printers.sh
Last active August 20, 2022 13:57 — forked from rmanly/unshare_all_printers.bash
Unshares printers and disables Printer Sharing
#!/bin/bash
#while read -r _ _ printer _; do
# /usr/sbin/lpadmin -p "${printer/:}" -o printer-is-shared=false
#done < <(/usr/bin/lpstat -v)
# Slightly faster when there are a lot of printers
lpstat -p | grep printer | cut -d" " -f2 | xargs -I{} lpadmin -p {} -o printer-is-shared=false
# Also disable Printer Sharing in the Sharing pane
cupsctl --no-share-printers
@jacobsalmela
jacobsalmela / recentServersSFL.py
Created December 28, 2015 15:22 — forked from pudquick/recentServersSFL.py
Working with SharedFileList (.sfl) files from OSX 10.11 El Capitan in python
from Foundation import NSKeyedUnarchiver
from struct import unpack
# This entire function is black magic of the highest order and I'll blog about it later
def extract_share(bookmark_data):
content_offset, = unpack('I', bookmark_data[12:16])
first_TOC, = unpack('I', bookmark_data[content_offset:content_offset+4])
first_TOC += content_offset
TOC_len, rec_type, level, next_TOC, record_count = unpack('IIIII', bookmark_data[first_TOC:first_TOC+20])
TOC_cursor = first_TOC + 20
@jacobsalmela
jacobsalmela / random_mnemonic.zsh
Created January 8, 2021 20:52 — forked from alexlovelltroy/random_mnemonic.zsh
This script uses the menemonic_wordlist from the mnemonic encoding project to generate a set of word pairs
#!/usr/bin/env zsh
#
# This script uses the menemonic_wordlist from the mnemonic encoding project to generate a set of word pairs
# I use them for software release naming conventions and I like choices
# You can get it for yourself with curl
# curl -Lo menmonic_wordlist.txt http://web.archive.org/web/20091003023412/http://tothink.com/mnemonic/wordlist.txt
#
#
MNEMONIC_FILE="$HOME/Documents/mnemonic_wordlist.txt"
function random_word {
@jacobsalmela
jacobsalmela / elf.h
Created November 28, 2022 12:34 — forked from mlafeldt/elf.h
elf.h for OSX
/* This is the original elf.h file from the GNU C Library; I only removed
the inclusion of feature.h and added definitions of __BEGIN_DECLS and
__END_DECLS as documented in
https://cmd.inp.nsk.su/old/cmd2/manuals/gnudocs/gnudocs/libtool/libtool_36.html
On macOS, simply copy the file to /usr/local/include/.
Mathias Lafeldt <mathias.lafeldt@gmail.com> */
/* This file defines standard ELF types, structures, and macros.
@jacobsalmela
jacobsalmela / go-build-all.sh
Created March 13, 2023 11:22 — forked from makew0rld/go-build-all.sh
Cross compile for all possible Golang targets. This script will always be updated, because it uses the `go` command to see what can be built.
#!/usr/bin/env bash
# Based on https://gist.github.com/eduncan911/68775dba9d3c028181e4
# but improved to use the `go` command so it never goes out of date.
type setopt >/dev/null 2>&1
contains() {
# Source: https://stackoverflow.com/a/8063398/7361270
[[ $1 =~ (^|[[:space:]])$2($|[[:space:]]) ]]