Skip to content

Instantly share code, notes, and snippets.

View palmerc's full-sized avatar

Cameron Lowell Palmer palmerc

View GitHub Profile
@palmerc
palmerc / userpic.sh
Last active March 19, 2024 13:02 — forked from acidprime/userpic.sh
Updating a user's picture from a script
#!/bin/bash
set -e
declare -x USERNAME="$1"
declare -x USERPIC="$2"
declare -r DSIMPORT_CMD="/usr/bin/dsimport"
declare -r ID_CMD="/usr/bin/id"
@palmerc
palmerc / math_commands.py
Last active March 17, 2024 17:37
Multiplication Worksheet
from pylatex import UnsafeCommand
from pylatex.base_classes import CommandBase
from pylatex.package import Package
class Multiplication(CommandBase):
_latex_name = 'mult'
_latex = r'''
$\begin{array}{rr}
@palmerc
palmerc / yaml2plist.py
Created February 28, 2024 14:54
Convert Ansible Inventory yaml to Remote Desktop importable plist
import yaml
import plistlib
import uuid
def main():
hosts = None
with open('inventory.yml') as f:
for yml in yaml.safe_load_all(f):
hosts = yml['all']['children']['production']['hosts']
@palmerc
palmerc / llvm-omp-setup.sh
Created August 26, 2014 09:45
Setup the LLVM compiler with the OpenMP extensions
ROOT_DIR=${PWD}
BUILD_DIR=${ROOT_DIR}/omp-src
INSTALL_DIR=/usr/local/llvm-omp
LLVM_SRC_DIR=${BUILD_DIR}/llvm
LLVM_BUILD_DIR=${BUILD_DIR}/llvm-build
CLANG_INCLUDE=${LLVM_SRC_DIR}/include
CLANG_BIN=${LLVM_BUILD_DIR}/Release+Asserts/bin
CLANG_LIB=${LLVM_BUILD_DIR}/Release+Asserts/lib
@palmerc
palmerc / ELKO_README.md
Last active November 14, 2023 12:31
Upgrade Elko Super Thermostat from 1.2.5R to 1.2.6R

Contact Elko support for the latest version of the thermostat firmware.

The version 1.2.6R package contained:

  • ap1.bin
  • avrboot.bin
  • elko_termo_og_boot.BAT

I bought a SanDisk 128GB SD card and formatted for FAT 32 using Disk Utility (macOS). I unzipped the package and copied the files over to the SD card at the command-line. I am using the command-line to avoid any magic the GUI versions might introduce. I also rm'ed any hidden directories and files introduced by the OS. Unmount/eject the SD card.

The upgrade procedure is quite simple actually. As it states on the back of the thermostat:

@palmerc
palmerc / no.corporate.wireguard.plist
Last active November 1, 2023 12:44
WireGuard LaunchD Startup
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>no.corporate.wireguard</string>
<key>RunAtLoad</key><true/>
<key>OnDemand</key><false/>
<key>Disabled</key><false/>
<key>WatchPaths</key>
@palmerc
palmerc / org.jenkins-ci.plist
Created August 26, 2014 13:23
Start script for Jenkins goes in /Library/LaunchDaemons
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>StandardOutPath</key>
<string>/var/log/jenkins/jenkins.log</string>
<key>StandardErrorPath</key>
<string>/var/log/jenkins/jenkins.log</string>
<key>EnvironmentVariables</key>
<dict>
@palmerc
palmerc / ocsp_check.py
Last active August 3, 2023 06:28
Apple OCSP Check
#!/usr/bin/env python3
import argparse
import pathlib
from cryptography import x509
from cryptography.x509 import ocsp
from cryptography.hazmat.primitives import serialization, hashes
import requests
@palmerc
palmerc / imageRoundtrip.swift
Last active February 20, 2023 23:46
Roundtrip a UIImage to its raw pixel values and back to an image again
import UIKit
import CoreGraphics
func imageFromPixelValues(pixelValues: [UInt8]?, width: Int, height: Int) -> CGImage?
{
var imageRef: CGImage?
if pixelValues != nil {
let imageDataPointer = UnsafeMutablePointer<UInt8>(pixelValues!)
let colorSpaceRef = CGColorSpaceCreateDeviceGray()
#!/bin/bash
# Remember to brew install libomp llvm
# I also build libressl
set -ex
ROOT_DIR=$( pwd )
SOURCE_DIR=${ROOT_DIR}/src