Skip to content

Instantly share code, notes, and snippets.

@lucasrangit
lucasrangit / dpkg-lock-monitor.sh
Last active February 17, 2022 13:09
Monitor DPKG lock file to determine which command acquired it and list its parent tree to determine why/how it was executed.
#!/usr/bin/env bash
set -o xtrace
set -o errexit
set -o pipefail
while true; do
pid=$(set +o pipefail; sudo fuser /var/lib/dpkg/lock-frontend 2>&1 | grep -o "[0-9]*" | head -n 1)
if [[ ! -z $pid ]]; then
sudo pstree -sa $pid
fi
@lucasrangit
lucasrangit / approve-closed-github-pr.user.js
Last active November 1, 2023 08:59
Tampermonkey/Greasemonkey UserScript to Allow Approving Closed GitHub PR
// ==UserScript==
// @name Approve Closed GitHub PR
// @namespace https://gist.github.com/lucasrangit/792324f4695babc701cdd64e18a63f4b
// @version 1.1
// @description A closed PR does not allow approval via the Web GUI. This adds the approval event back when submitting a retroactive review.
// @author Lucas Magasweran
// @match https://*.github.*/*/pull/*
// @grant none
// @require http://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
@lucasrangit
lucasrangit / wifi-load-test.sh
Created October 3, 2018 13:52
WIFI load test using virtual interfaces
#!/bin/bash
# this script creates multiple virtual interfaces
# all of these interfaces associate to the same AP to see how many associations the AP can handle
set -o errexit
set -o xtrace
DEVNAME=wlx0024a5219b70
CLIENTS=50
SSID=bhnt-vote
@lucasrangit
lucasrangit / xstat
Created April 25, 2018 13:55 — forked from XavierMarchena/xstat
xstat bash function to get file creation time on Linux with EXT4
#utility http://moiseevigor.github.io/software/2015/01/30/get-file-creation-time-on-linux-with-ext4/
xstat() {
#temporary file to be sorted
temp_file=$(mktemp)
for target in "${@}"; do
inode=$(ls -di "${target}" | cut -d ' ' -f 1)
@lucasrangit
lucasrangit / 98_dell_bios
Last active December 12, 2016 06:39
Dell XPS13 9333 grub and apt sources after do-release-upgrade 12.04 -> 14.04 -> 16.04
#!/bin/bash -e
source /usr/lib/grub/grub-mkconfig_lib
cat << EOF
menuentry "Flash BIOS using DOS" {
search --no-floppy --hint '(hd0,msdos1)' --set --fs-uuid 865C-483D
chainloader +1
}
EOF
@lucasrangit
lucasrangit / 0001-iio-dummy-add-shared-accel-enable.patch
Created August 4, 2016 23:31
Add shared accelerometer channel enable attribute
From 094ed79b63ecb8a11c9fa69041395f1459a336fa Mon Sep 17 00:00:00 2001
From: Lucas Magasweran <lucas.magasweran@daqri.com>
Date: Thu, 4 Aug 2016 16:24:43 -0700
Subject: [PATCH] iio: dummy: add shared accel enable
Signed-off-by: Lucas Magasweran <lucas.magasweran@daqri.com>
---
drivers/iio/dummy/iio_simple_dummy.c | 37 +++++++++++++++++++++++++++--
drivers/iio/dummy/iio_simple_dummy.h | 6 ++++-
drivers/iio/dummy/iio_simple_dummy_buffer.c | 2 +-
@lucasrangit
lucasrangit / gpio-int-test.c
Last active November 23, 2015 20:23
The `gpio-int-test.c` program uses `poll()` to wake up every 3 seconds (using `poll()` timeout mechanism) at which time it prints a period. Modified from https://www.ridgerun.com/wiki/index.php?title=Gpio-int-test.c to properly clear the initial state to avoid glitches and after an interrupt occurs so that the `poll()` blocks on next iteration.
/*
* Copyright (c) 2011, RidgeRun
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
@lucasrangit
lucasrangit / gist:d3415f8ce00d77d21026
Last active August 29, 2015 14:25
Photon analogRead
import urllib, urllib2
import json
from secrets import device_id, access_token
url = 'https://api.particle.io/v1/devices/'+device_id+'/analogread'
values = {
'params' : 'A0',
'access_token' : access_token,
}
#!/bin/bash
URL="http://flashair"
list () {
curl --silent "${URL}/command.cgi?op=100&DIR=${1}" \
| awk 'BEGIN { FS=","; OFS="/" } /.+,.+,[^0,]/ { print $1,$2 }'
}
files () {
for dir in $@; do
@lucasrangit
lucasrangit / CircularArray.java
Last active August 29, 2015 14:24
A generic CircularArray class that can be efficiently rotated and is iterable.
/*
* A generic CircularArray class that can be efficiently rotated and is
* iterable.
*/
import java.util.Iterator;
public class CircularArray implements Iterable<Object> {
private Object[] a;
private int r;