Skip to content

Instantly share code, notes, and snippets.

@adejones
adejones / gist:14acbc9165121047cf106ca32379c854
Created March 22, 2019 10:31
macOS pyenv install build failure help
# Xcode cli tools must be installed first, they have to be reinstalled after macOS version upgrades
xcode-select --install
# make sure Homebrew is up to date
brew update && brew upgrade
# change the version to be whichever one is failing
CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install -v 3.7.2
# found here: https://forums.macrumors.com/threads/el-capitan-bootable-dvd.1923931/#post-22036604
hdiutil attach /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
hdiutil convert /Volumes/install_app/BaseSystem.dmg -format UDSP -o /tmp/El\ Capitan
hdiutil resize -size 9g /tmp/El\ Capitan.sparseimage
hdiutil attach /tmp/El\ Capitan.sparseimage -noverify -nobrowse -mountpoint /Volumes/install_build
rm /Volumes/install_build/System/Installation/Packages
cp -rp /Volumes/install_app/Packages /Volumes/install_build/System/Installation/
cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/install_build
cp -rp /Volumes/install_app/BaseSystem.dmg /Volumes/install_build
@adejones
adejones / .screenrc
Last active April 1, 2018 07:30
Screen dotfile, based on Debian's default
# $Id: screenrc,v 1.15 2003/10/08 11:39:03 zal Exp $
#
# /etc/screenrc
#
# This is the system wide screenrc.
#
# You can use this file to change the default behavior of screen system wide
# or copy it to ~/.screenrc and use it as a starting point for your own
# settings.
#
#!/bin/sh
ffmpeg -i “$1″ -acodec alac “`basename “$1″ .flac`.m4a” \
-metadata title=\”"$(metaflac –show-tag=TITLE “$1″ | sed ‘s/title=//g’)”\” \
-metadata author=\”"$(metaflac –show-tag=ARTIST “$1″ | sed ‘s/artist=//g’)”\” \
-metadata album=\”"$(metaflac –show-tag=ALBUM “$1″ | sed ‘s/album=//g’)”\” \
-metadata year=\”"$(metaflac –show-tag=DATE “$1″ | sed ‘s/date=//g’)”\” \
-metadata track=\”"$(metaflac –show-tag=TRACKNUMBER “$1″ | sed ‘s/tracknumber=//g’)”\” \
-metadata genre=\”"$(metaflac –show-tag=GENRE “$1″ | sed ‘s/genre=//g’)”\”
@adejones
adejones / wine-app-with-xquartz.app
Created February 21, 2017 15:45
Script for Wine app using XQuartz. Open up Apple's Script Editor * Edit the program per the directions in the lines that start with -- * if everything is default, you only need to edit the "set toRun" line * After you have edited it for your program, save it as an "Application" (not a script) in the script editor * this will create a .app for yo…
on run
--edit this to be the correct location and file to run (typically only edit after the "drive_c")
set toRun to "$WINEPREFIX/drive_c/Program Files/MyProgram/MyProgramName.exe"
--edit winePrefix if you are not using the default prefix
set winePrefix to "$HOME/.wine"
--edit wineLocation if your wine install is not the default location
set wineLocation to "/usr/local/bin"
import logging
import logging.handlers
# log file name and logging message level
log_file_name = 'loggingexample.log'
log_level = logging.INFO
# log record format string
format_string = '%(asctime)s %(name)s %(levelname)s %(message)s'
import logging
# change default log entry format, set filename and logging level
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s", filename="example.log")
logging.info("Started")
logging.info("This is an example entry")
logging.debug("This line won't get logged as the log level is INFO")
logging.info("Done.")
# perform an orderly shutdown by flushing and closing all handlers; called at application exit and no further use of the logging system should be made after this call.
logging.shutdown()
rem cd to the full repo directory
cd path\to\full_repo
rem export tracked files in sub directory by creating a filemap using an intermediary temp file
set SUBDIR=name_of_subdir
hg locate -I "%SUBDIR%" > ..\filemap.tmp
for /f "tokens=*" %A in (..\filemap.tmp) do @echo include %A >> ..\filemap.txt
echo rename "%SUBDIR%" . >> ..\filemap.txt
del ..\filemap.tmp
# cd to the full repo directory
cd path/to/full_repo
# export tracked files in sub directory by creating a filemap
export SUBDIR=name_of_subdir
hg locate -I "$SUBDIR" | awk '{print "include \"" $1 "\"";}' > ../filemap.txt
echo "rename \"$SUBDIR\" ." >> ../filemap.txt
# create new repo using filemap
hg convert --filemap ../filemap.txt . ../new_repo_name
@adejones
adejones / checkmount.sh
Last active November 26, 2015 16:40
Check a mount point on Linux, attempt some recovery if the directory contains files then attempt mount -a
#!/usr/bin/env sh
# check if share is mounted, attempt recovery and remount
if [ -z "$1" ]; then
echo "Usage: $0 /mount/point/to/check"
exit 0
fi
DIR="$1"