Skip to content

Instantly share code, notes, and snippets.

@brimston3
brimston3 / NoSleep.au3
Last active December 7, 2024 17:54
Anti-idle autoit3 script. Use the windows idle timer to figure out the last input event. Useful when VMs don't have focus.
#cs
Copyright (C) March 30, 2015, Andrew Domaszek
(MIT License)
#ce
;#include <MsgBoxConstants.au3>
TraySetIcon ("Shell32.dll", 28)
TraySetToolTip ("Miggle" & @CRLF & "De-idle.")
Func _GetTicksFromGLII()
@brimston3
brimston3 / iso646_facepalm.c
Created March 13, 2015 20:10
iso646.h -- yet another reason we can't have nice things. At least it's not {di,tri}graphs.
#include <stdio.h>
#include <iso646.h>
int main() {
if (1 == 1 and 1 not_eq 2) {
printf("It's nice that it got here, but it still compiled.\n");
} else {
printf("Everything is awful, forever\n");
}
return 0;
@brimston3
brimston3 / printfTS.c
Created January 10, 2015 21:27
Example of C variadic macros and some vfprintf wrapping.
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
#include <time.h>
#define printfTS(msg, ...) fprintfTS(stdout, msg, ## __VA_ARGS__)
// This is *not* threadsafe (localtime & strftime)
int fprintfTS(FILE * stream, const char * const msg, ...)
{
@brimston3
brimston3 / printstatus.py
Created December 15, 2014 18:15
Because sometimes you really want your progress meter to print a QCD number from the '90s.
#!/usr/bin/env python
import sys
def printstatus():
ij=0
for i in range(printstatus.interject_len, 0, -1):
if printstatus.counter > 0 and (printstatus.counter % (len(printstatus.statline) * 3 ** i)) == 0:
print "\n%s" % printstatus.interject[i-1]
printstatus.lastmod=0
@brimston3
brimston3 / xattr_search
Created October 28, 2014 15:51
Search for particular xattribute in files and directories.
@brimston3
brimston3 / FLOW.sh
Created October 5, 2014 19:40
Linux HTB QoS script with source-based prioritization.
#!/bin/sh
# Bandwidth flow controller. Should decrease overall latency.
: <<'EOF'
Copyright (C) February 30, 2006, Andrew Domaszek
(MIT License)
Update history:
May 30, 2014 - add internal flow limit
@brimston3
brimston3 / autoscreen_with_procsetup.bashrc
Last active August 29, 2015 14:07
Automatic screen session setup/reattach at login.
if [ ! -z "$PS1" ] && [ -z "$STY" ] && which screen 2>&1 > /dev/null
then
old=$IFS
IFS=$'\n'
screens=($(screen -ls | egrep -iv '\(.*dead.*\)' | grep -e '(.*)' | awk '{print $1}'))
IFS=$old
if [ ${#screens[@]} -ge 1 ]; then
# pre-existing session, reattach to the first, leaving no bash parent behind.
exec screen -x "${screens[0]}"
else
@brimston3
brimston3 / date_correction.sql
Last active August 29, 2015 14:06
NOT TESTED!
DECLARE
FUNCTION date_if_possible(v1 IN VARCHAR2)
RETURN DATE AS
dte_corrected DATE;
BEGIN
dte_corrected = to_date(
to_char(to_number(regexp_substr(v1,'[^,]+', 15, 1)) - 100) ||
lpad(to_char(to_number(regexp_substr(v1,'[^,]+', 15, 2)) - 100),2,'0') ||
lpad(regexp_substr(v1,'[^,]+', 15, 3),2,'0') ||
lpad(regexp_substr(v1,'[^,]+', 15, 4),2,'0'),
@brimston3
brimston3 / autosys_hold_all.bash
Created July 15, 2014 11:59
multi-environment kill-and-hold for autosys... if this script would work for you, you should know on sight. I assume no liability from using parts of this script. {} string expansions need bash. Script tested in bash 4.2. You may need to re-alias jr and se before executing.
######## DO SETUP ########
e=accD
pre=UD
jildir=$DATDIR/../jil
for file in "`ls -1 \"$jildir\"`"
do
ostr=`grep delete_box $file | gawk -v s=$pre '{if (NR>1) {exit(0)};gsub(/\\\$S/,s,$2);print $2}'`
echo $ostr
stat=`jr $ostr | egrep '^'$ostr | sed -e 's@.* \([A-Z][A-Z]\) .*@\1@'`
echo $ostr $stat
@brimston3
brimston3 / array_contains.bash
Created July 14, 2014 18:03
A function to test if contents are in array. I probably swiped this from S.O. with minor alterations.
#!/bin/bash
function contains() {
local n=$#
local value=${!n}
for ((i=1;i < $#;i++)) {
if [ "${!i}" == "${value}" ]; then
return 0
fi
}