Skip to content

Instantly share code, notes, and snippets.

@thbounzer
thbounzer / systemd
Created February 29, 2016 10:13
logcheck systemd
^\w{3} [ :[:digit:]]{11} [._[:alnum:]-]+ systemd\[[[:digit:]]+\]: (Starting|Started) Session [[:digit:]]+ of user [^[:space:]]+\.$
^\w{3} [ :[:digit:]]{11} [._[:alnum:]-]+ systemd\[[[:digit:]]+\]: (Reexecuting|Reloading)\.$
^\w{3} [ :[:digit:]]{11} [._[:alnum:]-]+ systemd\[[[:digit:]]+\]: systemd [[:digit:]]+ running in system mode. \((\+[[:alnum:]]+ ?)+\)$
^\w{3} [ :[:digit:]]{11} [._[:alnum:]-]+ systemd\[[[:digit:]]+\]: Expecting device [^[:space:]]+\.device\.\.\.$
^\w{3} [ :[:digit:]]{11} [._[:alnum:]-]+ systemd\[[[:digit:]]+\]: Start(ing|ed) Cleanup of Temporary Directories\.+$
^\w{3} [ :[:digit:]]{11} [._[:alnum:]-]+ systemd\[[[:digit:]]+\]: Start(ing|ed) Run anacron jobs\.+$
^\w{3} [ :[:digit:]]{11} [._[:alnum:]-]+ systemd-logind\[[[:digit:]]+\]: New session [[:digit:]]+ of user [^[:space:]]+\.$
^\w{3} [ :[:digit:]]{11} [._[:alnum:]-]+ systemd-logind\[[[:digit:]]+\]: Removed session [[:digit:]]+\.$
^\w{3} [ :[:digit:]]{11} [._[:alnum:]-]+ systemd\[[[:digit:]]+\]: (Stopping|Stopped target|Reached target)
@thbounzer
thbounzer / audiomathdrill.rb
Created November 14, 2014 14:27
audiomathdrill
def speakthings a,b,op
%x{echo "#{a} #{op} #{b}" | espeak --stdin}
end
def singleop a,b,op,r
begin
puts " #{a}"
puts " #{op}"
puts " #{b}"
speakthings a,b,op
@thbounzer
thbounzer / snapper.sh
Created October 21, 2013 09:35
Daily webcam snapper
#!/bin/sh
mplayer tv:// -tv driver=v4l2:device=/dev/video0 -vo png:outdir=/out/dir/temp -flip -frames 40
name=$(date +%Y-%m-%d)
mv /out/dir/temp/00000040.png /out/dir/$name.png
rm /out/dir/temp/000000*.png
@thbounzer
thbounzer / glassparse.rb
Created July 23, 2013 14:33
Quick and dirty glassfish log parser and stat analyzer
require 'date'
require 'colorize'
# Parse glassfish default log files
# "X.X.X.X" "NULL-AUTH-USER" "22/Jul/2013:09:39:33 +0000" "POST /url/address/id HTTP/1.1" 200 7
# group things inside "" (?<=")(.*?)(?=")
# group things inside whitespaces (?<=\s)(.*?)(?=\s)
# last two digits parser
class LogLine
@thbounzer
thbounzer / regexps_tut.java
Created June 1, 2012 16:32
Reminder code for regexp parsing in java
final Pattern IP_PATTERN = Pattern.compile("\\A(\\d{1,3})[.](\\d{1,3})[.](\\d{1,3})[.](\\d{1,3})\z");
private boolean ipAddressValidator(String iPaddress){
Matcher m = IP_PATTERN.matcher(iPaddress);
boolean matches = m.matches();
boolean validIp = false;
int[] octects = extractIpOctets(iPaddress);
for(int octet: octects){
if (octet > 255){
validIp = false;
break;
@thbounzer
thbounzer / get_rf.rb
Created June 1, 2012 13:20
Get rf a2c modem state
require "net/https"
require "uri"
def check_rf(sitid)
magic_number = 1040187392+sitid.to_i
uri = URI.parse("https://sap2.astra2connect.com/tms/term/4-#{magic_number}/cgi-bin/modem_status")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
begin
@thbounzer
thbounzer / quakewhistle.rb
Created May 21, 2012 15:18
This is a ruby quick and dirty Italy earthquake whistle. It gets periodically the last tweet from INGVterremoti feed and it requires rubygems and twitter gem installed. Also requires beep package installed on the host machine. Beep frequency depends on ma
require "rubygems"
require "twitter"
tweet_f = Twitter.user_timeline("INGVterremoti").first.text
elements = tweet_f.split(/Ml:(\d.\d) (\d{4}-\d{2}-\d{2} \d{1,2}:\d{1,2}:\d{1,2}) UTC Lat=(\d{1,2}.\d{1,2}) Lon=(\d{1,2}.\d{1,2}) Prof=(\d{1,3}.\d{1,3})Km Prov=(\D*)/)
f_tstamp = elements[2]
while(true)
sleep(60*5)
tweet_s = Twitter.user_timeline("INGVterremoti").first.text
elements = tweet_s.split(/Ml:(\d.\d) (\d{4}-\d{2}-\d{2} \d{1,2}:\d{1,2}:\d{1,2}) UTC Lat=(\d{1,2}.\d{1,2}) Lon=(\d{1,2}.\d{1,2}) Prof=(\d{1,3}.\d{1,3})Km Prov=(\D*)/)
s_tstamp = elements[2]