Skip to content

Instantly share code, notes, and snippets.

View mapfel's full-sized avatar

Marko Apfel mapfel

View GitHub Profile
@mapfel
mapfel / gist:1451481
Created December 9, 2011 13:18
Batchprogrammierung: Ja/Nein-Abfrage
ECHO Rekursiv alle Ordnerinhalte unterhalb des Content-Ordner loeschen?
SET /P X= (J)a oder (N)ein?
IF /I "%X%"=="J" GOTO :LabelDelete
GOTO :LabelCollect
:LabelDelete
ECHO OFF
DEL /S /Q *.*>NUL
ECHO Dateien geloescht.
GOTO :LabelCollect
@mapfel
mapfel / gist:1451537
Created December 9, 2011 13:33
Batchprogrammierung: Parameter verwenden
IF "%1" == "" (SET Configuration=Debug) ELSE (SET Configuration=%1)
ECHO Configuration=%Configuration%
@mapfel
mapfel / gist:1451648
Created December 9, 2011 14:05
Batchprogrammierung: Prüfen ob Verzeichnis da ist und wenn nicht anlegen
IF NOT EXIST Content MKDIR Content
@mapfel
mapfel / .gitconfig
Last active December 11, 2020 13:27
Git configurations
[core]
autocrlf = True
# whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
# https://help.github.com/en/articles/associating-text-editors-with-git
editor = 'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin
[color]
ui = auto
@mapfel
mapfel / ArraySlicing1.rb
Last active December 16, 2015 06:09
Ruby - day 2: paging array content in slices of four
a = (1..16).to_a
a.each {|i| i % 4 == 0 ? (puts i) : (print i, ", ")}
@mapfel
mapfel / OwnGrep.rb
Created April 15, 2013 20:40
Ruby - day 2: little grep program
counter = 1
file = File.new($0, "r")
while (line = file.gets)
if line.include?("line")
puts "#{counter}: #{line}"
end
counter += 1
end
@mapfel
mapfel / HashToArrayAndReverse.rb
Created April 20, 2013 16:32
Ruby - day 2: hash to array and array to hash
a1 = ["a", 1, "b", 2]
h1 = Hash[*a1]
puts "a1=" + a1.to_s
puts "h1=" + h1.to_s
a2 = [["a", 1], ["b", 2]]
h2 = Hash[*a1] #splat operator (*) used
puts "a2=" + a2.to_s
puts "h2=" + h2.to_s
@mapfel
mapfel / HashIterate.rb
Created April 20, 2013 16:35
Ruby - day 2: iterate over hash
domains = { :de => "DEU", :no => "NOR", :us => "US" }
domains.each_pair { |k, v| puts "Key: #{k}, Value: #{v}" }
@mapfel
mapfel / default.zsh-theme
Last active August 29, 2015 13:57
MBP zsh prompt with GIT and battery status
ZSH_THEME_GIT_PROMPT_PREFIX="[git:"
ZSH_THEME_GIT_PROMPT_SUFFIX="]$reset_color"
ZSH_THEME_GIT_PROMPT_DIRTY="$fg[red]+"
ZSH_THEME_GIT_PROMPT_CLEAN="$fg[green]"
function git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_PREFIX$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX"
}
@mapfel
mapfel / batcharge.py
Created March 8, 2014 19:17
Battery analysis for zsh-theme
#!/usr/bin/env python
# coding=UTF-8
import math, subprocess
p = subprocess.Popen(["ioreg", "-rc", "AppleSmartBattery"], stdout=subprocess.PIPE)
output = p.communicate()[0]
o_max = [l for l in output.splitlines() if 'MaxCapacity' in l][0]
o_cur = [l for l in output.splitlines() if 'CurrentCapacity' in l][0]