Skip to content

Instantly share code, notes, and snippets.

View bobbzorzen's full-sized avatar

Leopold Olsson bobbzorzen

View GitHub Profile
function areaOfCylinder($r,$h) {
$areaOfCircle = pi()*pow($r,2);
$areaOfCircles = $areaOfCircle*2;
$areaAround = $h*(2*(pi()*$r));
$totalArea = $areaOfCircles+$areaAround;
return $totalArea;
}
@bobbzorzen
bobbzorzen / rawr.sh
Created December 13, 2013 10:07
Sed magix
<q1dataclean.txt sed -n 's/(.*\/\([A-Z][a-z]\{2\}[0-9]\{4\}AD\)[0-9A-Z].*>\([A-Z][a-z]\{2\}[0-9]\{4\}AD\))/({2012AD\21944AD\1})/p;s/(.*>\([A-Z][a-z]\{2\}[0-9]\{4\}AD\))/({2012AD\11944AD})/p;s/(.*\/\([A-Z][a-z]\{2\}[0-9]\{4\}AD\)[0-9A-Z].*)/({2012AD1944AD\1})/p;s/(\/.*)/({2012AD1944AD})/p'
@bobbzorzen
bobbzorzen / The path to sed mastery.sh
Created December 19, 2013 09:16
A Sed assignment
1a <q1dataclean.txt sed -n 's/(.*\/\([A-Z][a-z]\{2\}[0-9]\{4\}AD\)[0-9A-Z].*>\([A-Z][a-z]\{2\}[0-9]\{4\}AD\))/({2012AD\21944AD\1})/p;s/(.*>\([A-Z][a-z]\{2\}[0-9]\{4\}AD\))/({2012AD\11944AD})/p;s/(.*\/\([A-Z][a-z]\{2\}[0-9]\{4\}AD\)[0-9A-Z].*)/({2012AD1944AD\1})/p;s/(\/.*)/({2012AD1944AD})/p'
1b I prayed to the sed gods to enlighten me, and so it was. The sed MASTER was born. Or maybe i just watched a 40m youtube tutorial to learn sed and then spend 3h ripping my hair out followed by another 2h of experimenting with regex, backreferencing, nagging at the teacher and then some comparing my result with the proper hits file.
2a < q2dataclean.txt sed -n 's/^\(0x[a-z0-9]\{3\}\)\([1-9][0-9]\{0,1\}:[0-9]\{1,2\}[amp]\{2\}\).*/<([Jane|Alice|\2|Mary|\1])>/p ; s/^\(0x[a-z0-9]\{3\}\)[^1-9].*/<([Jane|Alice||Mary|\1])>/p'
2b I spent aproximately 20-30 minutes identifying the replace pattern and then aproximately 1-2h constructing a pattern that i thougth would match. it turned out i had written some of my numerical charact

6 simple techniques for getting 15 sentences of report text


  1. Write down the questions!

    Writing down the questions you're supposed to answer is a great way to increase the sentence count. there are usually 3-4 of them so if you write them down you're almost a third of the way there.

  2. Did you miss a semicolon somewhere?

#!/bin/bash
function child()
{
while true; do
filename='currentip.txt'
oldIp=`cat $filename`
currentIp=`curl http://bot.whatismyipaddress.com/`
if [ $oldIp != $currentIp ]
then
@bobbzorzen
bobbzorzen / analyze.js
Created October 15, 2014 14:56
text analysis
javascript:
var highlightedText = window.getSelection().toString();
highlightedText = highlightedText.replace("?",".");
highlightedText = highlightedText.replace("!",".");
highlightedText = highlightedText.replace(/\.\.*/g,".");
var sentances = highlightedText.split(".");
var sentanceCount = (highlightedText.match(/\.\s/g) != null) ? highlightedText.match(/\.\s/g).length : 0;
sentanceCount += (highlightedText.slice(-1) == ".") ? 1:0;
var wordCount = highlightedText.split(" ").length;
var avgWordsPerSentance = (wordCount/sentanceCount).toFixed(2);
@bobbzorzen
bobbzorzen / AppendToQueryString.js
Last active August 17, 2016 13:35
A simple method to append to current querystring
appendToQueryString = function (param, val) {
var queryString = window.location.search.replace("?", "");
var parameterListRaw = queryString === "" ? [] : queryString.split("&");
var parameterList = {};
var newQueryString = "?";
for (var i = 0; i < parameterListRaw.length; i++) {
var parameter = parameterListRaw[i].split("=");
parameterList[parameter[0]] = parameter[1];
}
@bobbzorzen
bobbzorzen / networkTest.py
Created December 26, 2016 11:51
Small script that tracks network uptime and logs it to file
import time
import datetime
import socket
# import urllib2
def hasInternet(host="8.8.8.8", port=53, timeout=3):
"""
Host: 8.8.8.8 (google-public-dns-a.google.com)
OpenPort: 53/tcp
Service: domain (DNS/TCP)
@bobbzorzen
bobbzorzen / TicketeerTimesheetIntegration.js
Last active April 30, 2018 07:24
A greasemonkey/tampermonkey script to fetch times from ticketeer and auto report to maconomy
// ==UserScript==
// @name Ticketeer Timesheet Integration Dev
// @namespace my.Home
// @version 1.0
// @description Makes your life better one friday at a time
// @author Tommy Svenningsson
// @grant none
// @match https://ter.istone.com/cgi-bin/Maconomy/*
// @require https://code.jquery.com/jquery-3.1.1.min.js
// ==/UserScript==
tArgs = {...}
local rows = tonumber(tArgs[1])
local columns = tonumber(tArgs[2])
local enderchest_index = tonumber(tArgs[3] or -1)
y = 0
print(string.format("Filling %s by %s area with refill chest on index %s", rows, columns, enderchest_index))
function refillFromEnderchest()
turtle.select(enderchest_index)