Skip to content

Instantly share code, notes, and snippets.

View pamolloy's full-sized avatar

Philip Molloy pamolloy

View GitHub Profile
@pamolloy
pamolloy / 0001-env-Exit-tools-when-invalid-CRC-found.patch
Last active August 27, 2019 22:12
U-Boot patch to exit userspace tools when an invalid CRC is found
From 6482180e602c4853e43d5c5a40b3349b63aba276 Mon Sep 17 00:00:00 2001
From: Philip Molloy <philip-molloy@idexx.com>
Date: Tue, 2 Apr 2019 17:02:48 -0400
Subject: [PATCH 1/1] env: Exit tools when invalid CRC found
fw_setenv and fw_printenv currently print a warning and use a default
environment compiled into the binary when an invalid CRC is found. This
modifies the default behavior to print an error and exit. This is
especially important when calling the tools from a script since the
script depends on the exit code of the tool to know something went
@pamolloy
pamolloy / README.md
Last active February 26, 2019 15:28
Enabling EEPROM support in U-Boot

Selecting CONFIG_SYS_I2C_ZYNQ and CONFIG_ZYNQ_I2C0 builds successfully (see Xilinx documentation). But those are old config options and should be replaced with CONFIG_I2C_CADENCE.

Selecting CONFIG_ENV_IS_IN_EEPROM causes the following assertion to fail:

cmd/eeprom.c:58:2: error: #error CONFIG_SYS_I2C_EEPROM_ADDR_LEN must be 1 or 2
 #error CONFIG_SYS_I2C_EEPROM_ADDR_LEN must be 1 or 2
  ^~~~~

...
@pamolloy
pamolloy / README.md
Last active January 23, 2019 20:55
Irssi notifications

I keep running into the following issue:

Jan 23 15:48:52 localhost irssi-notify.bash[23391]: ssh_askpass: exec(/usr/libexec/openssh/ssh-askpass): No such file or directory
Jan 23 15:48:52 localhost irssi-notify.bash[23391]: user@host: Permission denied (publickey).

After I installed openssh-askpass I get prompted for the password for my key every time ssh is called in the script.

@pamolloy
pamolloy / driver.c
Last active October 17, 2018 15:26
Disabling runtime power management does not disable autosuspend
#include <linux/module.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/of_gpio.h>
#include <linux/pm_runtime.h>
#define MODULE_NAME "device"
#! /bin/sh
NAME=foo
DAEMON=/root/$NAME
case "$1" in
start)
printf "Starting $NAME: "
start-stop-daemon -S -q -b -x $DAEMON
[ $? = 0 ] && echo "OK" || echo "FAIL"
@pamolloy
pamolloy / remote-load-rrd-dump.xml
Last active November 14, 2016 15:14
Remote load RRD dump
This file has been truncated, but you can view the full file.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE rrd SYSTEM "http://oss.oetiker.ch/rrdtool/rrdtool.dtd">
<!-- Round Robin Database Dump -->
<rrd>
<version>0003</version>
<step>10</step> <!-- Seconds -->
<lastupdate>1469481585</lastupdate> <!-- 2016-07-25 17:19:45 EDT -->
<ds>
<name> shortterm </name>
@pamolloy
pamolloy / ptoken.c
Created June 21, 2012 16:20
Parsing strings with multiple delimiters
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *sep[] = {";", "=", ":", ",", NULL};
char string[] = "entertitle=uncollapse,grabkeys;"
"enterslave=grabkeys;leaveslave=collapse,ungrabkeys;"
"button1=menuexec;button2=togglestick;button3=exit:13;"
"button4=scrollup;button5=scrolldown;"
"key_Up=scrollup;key_Down=scrolldown;"
@pamolloy
pamolloy / latex.sh
Last active January 1, 2016 16:39
Install vim LaTeX software
aptitude install texlive-full texlive-math-extra gnuplot
pdflatex example.tex
aptitude install vim-latexsuite
vim-addons install latex-suite
@pamolloy
pamolloy / qemu.sh
Created December 29, 2013 16:23
Install, setup and run a QEMU image
aptitude update
aptitude full-upgrade
aptitude install qemu
qemu-img create -f qcow2 image.qcow2 5G
qemu -hda image.qcow2 -cdrom debian-7.2.0-i386-netinst.iso -boot d -m 256
qemu -hda image.qcow2 -m 256
@pamolloy
pamolloy / example.vbs
Last active December 31, 2015 03:49
Using VBScript function procedures open a text file and also modify one cell in an Excel worksheet
' Introduction to Scripting Microsoft Office - http://technet.microsoft.com/en-us/library/ee176994.aspx
strExcelFilename = "C:\Users\Philip\Desktop\report_template.xls"
strPLNFilename = "C:\Users\Philip\Desktop\sample.pln"
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const row = 13, col = 1, text = "Test"
Function OpenFileRead(FileName)
Set objFileSystemObject = CreateObject("Scripting.FileSystemObject")
If objFileSystemObject.FileExists(FileName) Then ' Check if the file exists
Set objFile = objFileSystemObject.OpenTextFile(FileName, ForReading)