Skip to content

Instantly share code, notes, and snippets.

@raidzero
raidzero / gist:234480a144c3b8092c8ddcef76b4abd5
Created Feb 13, 2019
rudimentary raise command for swaymsg
View gist:234480a144c3b8092c8ddcef76b4abd5
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;
View untitled.scad
$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 Jun 14, 2018
switch box scad design
View base.scad
// 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
View current ram used in percent
#include <stdio.h>
int main(void) {
FILE* fp = fopen("/proc/meminfo", "r");
if (fp != NULL) {
char buf[128];
int total, avail;
View Cpu usage over the last second
#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 Apr 29, 2018
hide/show windows on given workspace when focusing/unfocusing workspace
View musicwatcher.py
#!/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 Jun 28, 2016
get list of running & queued builds on a teamcity server
View tcbuilds.py
#!/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 Jun 7, 2016
Auto block port scanners from openvpn server
View ipblock.sh
#!/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 Apr 25, 2016
show git branch in command prompt
View .bashrc
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 Dec 22, 2015
groovy extract date range in days from xml (for soapui)
View dates.groovy
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