Skip to content

Instantly share code, notes, and snippets.

View mapfel's full-sized avatar

Marko Apfel mapfel

View GitHub Profile
@mapfel
mapfel / variant.01.cs
Last active August 4, 2020 15:01
ASP.NET Core - Run vs. RunAsService
// https://dotnetthoughts.net/how-to-host-your-aspnet-core-in-a-windows-service/
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseIISIntegration()
.UseKestrel()
.UseContentRoot(@"Path\To\Content\Root")
.UseStartup<Startup>()
.Build();
@mapfel
mapfel / whitelist.txt
Last active May 10, 2025 07:00
Pi-Hole Whitelist for SpOn (Spiegel Online) and Bild.de
# Defaults
# ========
# see also https://raw.githubusercontent.com/pi-hole/pi-hole/master/adlists.default
# Hosts-file.net
# https://hosts-file.net/ad_servers.txt
hosts-file.net
# MalwareDomains
# https://mirror1.malwaredomains.com/files/justdomains
@mapfel
mapfel / Git-Repository.flt
Created September 19, 2017 20:21
filter template for WinMerge to suppress the hidden .git folder
## This is a directory/file filter template for WinMerge
name: Git-Repository
desc: Suppresses the hidden .git Folder which contains the (lokal) repository
## Select if filter is inclusive or exclusive
## Inclusive (loose) filter lets through all items not matching rules
## Exclusive filter lets through only items that match to rule
## include or exclude
def: include
#!/bin/bash -e
####
# Helper script to update the Last modified timestamp of files in a Git SCM
# Projects working Copy
#
# When you clone a Git repository, it sets the timestamp of all the files to the
# time when you cloned the repository.
#
# This becomes a problem when you want the cloned repository, which is part of a
# Web application have a proper cacheing mechanism so that it can re-cache files
@mapfel
mapfel / Mac OS X
Last active August 29, 2015 14:16
Show & Hide hidden files (1)
defaults write com.apple.finder AppleShowAllFiles -bool YES
defaults write com.apple.finder AppleShowAllFiles -bool NO
Show & Hide hidden files (2)
defaults write com.apple.finder AppleShowAllFiles 1 && killall Finder
Display full Path in OS X Finder title Bar
defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
@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]
@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 / 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 / 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 / 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