Skip to content

Instantly share code, notes, and snippets.

@robsonke
robsonke / createTreeStructureFromArray.php
Created June 14, 2014 08:17
Group a php array to a tree structure
$original = array
(
"1" => array
(
"id" => 1,
"type" => "mtb",
"brand" => "scott",
"name" => "scott1"
),
array
-- Modified script, based on:
-- http://peterdowns.com/posts/open-iterm-finder-service.html
on run {input, parameters}
tell application "Finder"
set dir_path to quoted form of (POSIX path of (folder of the front window as alias))
end tell
CD_to(dir_path)
end run
#!/bin/sh
#
#
# Usage: ./scriptName.sh www.google.com
#
ADDRESS=$1
echo Fetching ssl certificate for $ADDRESS
on alfred_script(q)
tell application "iTerm"
activate
tell the first terminal
launch session "Default"
tell the last session
-- give the iterm tab the name of the process
set name to q
@robsonke
robsonke / checkDockerDisks.sh
Last active September 30, 2024 09:34
This Bash script will loop through all running docker containers on a host and list the disk usage per mount. In case it's breaching the 65%, it will email you.
#!/bin/bash
# get all running docker container names
containers=$(sudo docker ps | awk '{if(NR>1) print $NF}')
host=$(hostname)
# loop through all containers
for container in $containers
do
echo "Container: $container"
@robsonke
robsonke / switchOsxLocation.sh
Last active May 9, 2016 06:48
A simple bash script switching osx locations based on the active wifi network
#! /bin/bash
#######################################################
## Simple bash script to change OSX network location ##
## based on the wifi network you're connected too. ##
## Author: Rob Sonke ##
#######################################################
#
# NOTE: Make sure you add this line to the /etc/sudoers file to allow
@robsonke
robsonke / resize-images.sh
Last active September 10, 2016 12:15
Resizes and renames image files in the current directory using sips (osx). Can be rewritten to imagemagick easily to make it work on Linux too.
# Given a collection of image files, this function will resize
# the images in the current folder and saves them in the subfolder resized
#
# Usage: resize-images
# Note: the read command is specific for ZSH shells, for Bash, use -p param. Same for the setopt, it's shopt for bash.
#
## Resize and rename images in the current directory and writes them to a resized subfolder
function resize-images() {
read "filename?What would you like the filename to be started with? []: "
read "width?What max width in pixels would you like your images? [1024]: "
@robsonke
robsonke / soundnodeapp.py
Created December 11, 2016 07:55
This lets soundnodeapp uses your own client id and eliminates the api limit.
import getpass
import json
import re
import requests
client_id = re.compile(',client_id:"(.*?)"').search(requests.get(re.compile('src="https://a-v2.sndcdn.com/assets/app-.*.js"').search(requests.get('https://soundcloud.com/').text).group()[5:-1]).text).group()[12:-1]
username = raw_input('Username: ')
password = getpass.getpass()
#!/bin/sh
#############################################
## Bash script to cleanup git repositories ##
## Author: Rob Sonke ##
#############################################
# To execute this in all subdirs of the current dir:
# for d in ./*
# do
# (cd $d && ~/Downloads/removeOldBranches.sh)
#!/bin/bash
#
# Simple Bash script to fix a merge conflict with either mine or yours as option
#
# @author R. Sonke
#
bold=$(tput bold)
normal=$(tput sgr0)
doTheMerge () {