Skip to content

Instantly share code, notes, and snippets.

@raidzero
raidzero / gist:234480a144c3b8092c8ddcef76b4abd5
Created February 13, 2019 02:33
rudimentary raise command for swaymsg
diff --git a/include/sway/commands.h b/include/sway/commands.h
index 3ed00763..ae1e3f31 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -154,6 +154,7 @@ sway_cmd cmd_no_focus;
sway_cmd cmd_output;
sway_cmd cmd_permit;
sway_cmd cmd_popup_during_fullscreen;
+sway_cmd cmd_raise;
sway_cmd cmd_reject;
@raidzero
raidzero / untitled.scad
Created September 13, 2018 00:43
scad test
$fn = 50;
// distance between holes in the linear bearing
bearing_hole_distance = 18;
// diameter of the m4 holes in the linear bearing
bearing_hole_diameter = 3.9;
// how much space to the left and right of the holes
bearing_plate_padding = 2.5;
@raidzero
raidzero / base.scad
Created June 14, 2018 20:06
switch box scad design
// make a 75wx40dx25h hollow square
height = 25;
width = 75;
depth = 45;
thickness = 2;
// stereo jack/switch mounting holes
hole_diameter = 6;
// width of corner support columns
#include <stdio.h>
int main(void) {
FILE* fp = fopen("/proc/meminfo", "r");
if (fp != NULL) {
char buf[128];
int total, avail;
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#define BUF_SIZE 4096
typedef struct {
unsigned long int user;
unsigned long int nice;
unsigned long int system;
@raidzero
raidzero / musicwatcher.py
Last active April 29, 2018 20:28
hide/show windows on given workspace when focusing/unfocusing workspace
#!/usr/bin/env python
import i3ipc
import subprocess
# process all windows on this workspace. hide when leaving and show when entering
# because chrome/ium doesnt consider itself hidden when on an invisible workspace
# this script drops my cpu usage when listening to google music from ~10% to ~3%
MUSIC_WS_INDEX = 6
@raidzero
raidzero / tcbuilds.py
Created June 28, 2016 17:02
get list of running & queued builds on a teamcity server
#!/usr/bin/env python
import base64
import os
import sys
import urllib2
import xml.etree.ElementTree
def openUrl(urlStr, user, passwd):
req = urllib2.Request(urlStr)
authStr = base64.encodestring('%s:%s' % (user, passwd)).strip()
@raidzero
raidzero / ipblock.sh
Created June 7, 2016 19:29
Auto block port scanners from openvpn server
#!/bin/bash
# this parses the openvpn connection log for any suspected attackers and blocks them, also uses geoiplookup to show the country :)
LIST=$1
COUNT=0
for IP in `cat /var/log/openvpn.log | grep attack | grep -oE "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" | sort -u`; do
LOCATION=`geoiplookup $IP | awk -F ": " '{print$2}'`
if [ -z "$LIST" ]; then
# check for existing rule
@raidzero
raidzero / .bashrc
Created April 25, 2016 20:56
show git branch in command prompt
function get_git_branch_prompt() {
echo " `git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\(\1\)\ /'`"
}
function git_prompt {
local __git_branch='`get_git_branch_prompt`'
export PS1="\@ \W\[\033[32m\]$__git_branch\[\033[00m\]\$ "
}
git_prompt
@raidzero
raidzero / dates.groovy
Last active December 22, 2015 19:40
groovy extract date range in days from xml (for soapui)
import groovy.time.TimeCategory
// create XmlHolder for request content
def holder = new com.eviware.soapui.support.XmlHolder( mockRequest.requestContent )
// get arguments
def startDateStr = holder["//b:StartDate"]
def endDateStr = holder["//b:EndDate"]
log.info "start: " + startDateStr + " end:" + endDateStr