Skip to content

Instantly share code, notes, and snippets.

View blurayne's full-sized avatar

Markus Geiger blurayne

View GitHub Profile
@splaspood
splaspood / bash_iniparse.sh
Created December 13, 2011 20:34
Parsing INI Files with Bash
cfg.parser () {
fixed_file=$(cat $1 | sed 's/ = /=/g') # fix ' = ' to be '='
IFS=$'\n' && ini=( $fixed_file ) # convert to line-array
ini=( ${ini[*]//;*/} ) # remove comments
ini=( ${ini[*]/#[/\}$'\n'cfg.section.} ) # set section prefix
ini=( ${ini[*]/%]/ \(} ) # convert text2function (1)
ini=( ${ini[*]/=/=\( } ) # convert item to array
ini=( ${ini[*]/%/ \)} ) # close array parenthesis
ini=( ${ini[*]/%\( \)/\(\) \{} ) # convert text2function (2)
ini=( ${ini[*]/%\} \)/\}} ) # remove extra parenthesis
@cowboy
cowboy / sudo-keepalive-example.sh
Created July 15, 2012 20:55
Bash: Sudo keep-alive (good for long-running scripts that need sudo internally but shouldn't be run with sudo)
#!/bin/bash
# Might as well ask for password up-front, right?
sudo -v
# Keep-alive: update existing sudo time stamp if set, otherwise do nothing.
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Example: do stuff over the next 30+ mins that requires sudo here or there.
function wait() {
@jpouellet
jpouellet / zbell.sh
Last active November 24, 2023 10:49
Makes Zsh print a bell when long-running commands finish. I use this in combination with i3 and throw big compile jobs (or whatever it may be) into another workspace to get a nice visual notification (workspace indicator turns red) when it's done so I don't need to waste time regularly checking on it.
#!/usr/bin/env zsh
# This script prints a bell character when a command finishes
# if it has been running for longer than $zbell_duration seconds.
# If there are programs that you know run long that you don't
# want to bell after, then add them to $zbell_ignore.
#
# This script uses only zsh builtins so its fast, there's no needless
# forking, and its only dependency is zsh and its standard modules
#
@thomedes
thomedes / ini.sed
Last active August 17, 2023 20:41
sed one-liners to deal with .ini / .conf files
# List all [sections] of a .INI file
sed -n 's/^[ \t]*\[\(.*\)\].*/\1/p'
# Read KEY from [SECTION]
sed -n '/^[ \t]*\[SECTION\]/,/\[/s/^[ \t]*KEY[ \t]*=[ \t]*//p'
# Read all values from SECTION in a clean KEY=VALUE form
@tourist
tourist / mmr_workout_gpx_export.py
Last active December 5, 2022 16:12
Exports workouts data from MapMyFitness API (MapMyRun and other MapMy* apps) to *.gpx file including timestamps. Might be used to import to another apps. MapMyFitness web interface offers export to *.gpx but without timestamps. Originaly used to move my data to Endomondo.
# quick & dirty export of workouts to *.gpx file with timestamps from MapMyFitness API
# for purpose of moving to other apps (tested with Endomondo)
# based on: https://developer.mapmyapi.com/docs/read/Authentication2
# needs API access request "Request a key" @ https://developer.mapmyapi.com/
from __future__ import unicode_literals
import requests
import urlparse
import webbrowser
import json
from requests_oauthlib import OAuth2
@dwayne
dwayne / 00-introduction.md
Last active November 5, 2022 23:05
How to build a Hypermedia-Driven REST API - Notes
@staltz
staltz / introrx.md
Last active May 26, 2024 06:18
The introduction to Reactive Programming you've been missing
@nolstedt
nolstedt / gist:9dd7835b874e6d6bc64d
Created June 26, 2014 08:37
rsync copy/move with progress, cp mv progress
alias rsynccopy='rsync --partial --progress --append --rsh=ssh -r -h '
alias rsyncmove='rsync --partial --progress --append --rsh=ssh -r -h --remove-sent-files'
@pklaus
pklaus / ddnsserver.py
Last active February 27, 2024 11:41 — forked from andreif/Simple DNS server (UDP and TCP) in Python using dnslib.py
Simple DNS server (UDP and TCP) in Python using dnslib.py
#!/usr/bin/env python
"""
LICENSE http://www.apache.org/licenses/LICENSE-2.0
"""
import argparse
import datetime
import sys
import time
import threading
@tuxfight3r
tuxfight3r / 01.bash_shortcuts_v2.md
Last active May 23, 2024 16:51
Bash keyboard shortcuts

Bash Shortcuts

visual cheetsheet

Moving

command description
ctrl + a Goto BEGINNING of command line