Skip to content

Instantly share code, notes, and snippets.

@erichschroeter
erichschroeter / 74x165.h
Last active Oct 10, 2015
Linux driver for 74x165 PISO chip.
View 74x165.h
#ifndef LINUX_SPI_74X165_H
#define LINUX_SPI_74X165_H
struct nxp_74x165_chip_platform_data {
/* number assigned to the first GPIO */
unsigned base;
/* GPIO used for latching chip(s) */
unsigned latch;
/* number of chips daisy chained */
unsigned daisy_chained;
@erichschroeter
erichschroeter / file_completion.patch
Created Oct 9, 2012
dmenu filename tab completion
View file_completion.patch
--- dmenu.c 2012-10-09 15:30:08.605004976 -0500
+++ dmenu.c 2012-10-09 15:46:59.318016781 -0500
@@ -5,6 +5,7 @@
#include <string.h>
#include <strings.h>
#include <unistd.h>
+#include <wordexp.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
@erichschroeter
erichschroeter / queue.sh
Created Nov 28, 2012
Shell script implementation of a Queue.
View queue.sh
#!/bin/bash
#
# This script encapsulates the functionality of a queue. It requires there to be
# an input file with the data in the queue being separated on different lines.
#
INPUT=queue.txt
OUTPUT=trash.txt
CMD=/usr/bin/vlc
@erichschroeter
erichschroeter / termios_dbg.c
Created Jun 7, 2013
Debug statements for termios struct.
View termios_dbg.c
#include <stdio.h>
#include <sys/ioctl.h>
#include "termios_dbg.h"
#define CHECK_BIT(var, pos) ((var) & (1<<(pos)))
void ptermios_iflag(struct termios *tty)
{
printf("c_iflag=0x%x\n", tty->c_iflag);
@erichschroeter
erichschroeter / batt.py
Created Nov 15, 2013
Print the battery percentage using colors for High, Medium, Low battery levels. Uses acpitool to parse for battery percentage level.
View batt.py
#!/usr/bin/env python
# coding=UTF-8
import sys, subprocess
p = subprocess.Popen(["acpitool", "-ab"], stdout=subprocess.PIPE)
output = p.communicate()[0]
# find the line with the battery percentage
o_cur = [l for l in output.splitlines() if '%' in l][0]
@erichschroeter
erichschroeter / timer_unix.c
Last active Nov 9, 2018
Cross-platform timer example in C.
View timer_unix.c
#include <stdio.h>
#include <time.h>
#define PRINT_INTERVAL 1000 /* in milliseconds */
#define MILLI 0
#define MICRO 1
#define NANO 2
#define RESOLUTION MILLI
long diff_nano(struct timespec *start, struct timespec *end)
View Makefile
.PHONY: clean uninstall
prefix ?= /usr
exec_prefix ?= $(prefix)
bindir ?= $(exec_prefix)/bin
ETHERWAKE_src = ether-wake.c
ETHERWAKE_bin = ether-wake
ETHERWAKE_tgt = $(DESTDIR)$(bindir)/etherwake
@erichschroeter
erichschroeter / HelloLibrary.cs
Created Apr 25, 2014
Simple marshalling hello world with nested struct.
View HelloLibrary.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace HelloApp
{
class HelloLibrary
{
@erichschroeter
erichschroeter / HelloLibrary.cs
Last active Aug 21, 2021
A helloworld example of marshalling an array to C# created in C.
View HelloLibrary.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace HelloApp
{
class HelloLibrary
{
@erichschroeter
erichschroeter / req.sh
Created Jun 13, 2014
Requirement management based on Git.
View req.sh
#!/bin/sh
usage() {
cat << EOF
usage: req [--version] [--help] <command> [<args>]
The most commonly used req commands are:
add Add requirement contents to the index
new Create a requirement
init Create an empty req repository