Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / xattr_search
Created October 28, 2014 15:51
Search for particular xattribute in files and directories.
@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 / 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 / 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 / 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()
#!/usr/bin/lua
--[[
Copyright (C) February 10, 2016, Andrew Domaszek
(MIT License)
Wrote this lua demonstrator for Joe
Show some basics on how to do index-lookup-based function indirection instead
of an if-elseif cascade and keep a table of global state. I suspect the keystate
variable could be declared global instead of manually set in _G, but I've only done
#include "stdio.h"
// Only for extremely evil people
#undef NULL
#define NULL 7
int main()
{
printf("%d\n", NULL);
return 0;