Skip to content

Instantly share code, notes, and snippets.

View whiskey's full-sized avatar

Carsten Knoblich whiskey

View GitHub Profile
@whiskey
whiskey / email-matching-demo.py
Last active May 16, 2025 08:56
RegEx - Catastrophic Backtracking demo
import re
import time
regex = r"\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+"
for test_str in ["firstname.lastname@example-domain.com", "firstname.lastname@example-domain.c"]:
print('starting matching')
start_time = time.time()
matches = re.finditer(regex, test_str, re.MULTILINE)
for matchNum, match in enumerate(matches, start=1):
@whiskey
whiskey / defence_in_depth.svg
Created December 19, 2024 08:30
Defence in Depth
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@whiskey
whiskey / blink.py
Created April 24, 2024 11:07
Make miro items blink
@whiskey
whiskey / xcode-icon-tag.sh
Last active September 26, 2019 12:16 — forked from valeriomazzeo/xcode-icon-tag.sh
Xcode Icon Version Overlay
# xcode-icon-tag.sh
# The MIT License (MIT)
#
# Copyright (c) <2015> <Valerio Mazzeo>
# Permission is hereby granted, free of charge, to any person obtaining a copy
#
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
#!/usr/bin/env sh
#
# Having multiple git remotes in sync with one `push`
# via: https://gist.github.com/rvl/c3f156e117e22a25f242
#
set -e
NEW_REPO_URL=<NEW_REPO_URL>
let pat = "(^\\w)[\\w]+[\\. ]?(^\\w)?[\\w]+" // FIXME: does not catch the 2nd initial 🙁
let emails = ["john@foo.com", "john.doe@foo.com", "John Doe"]
let regex = try! NSRegularExpression(pattern: pat, options: [])
emails.forEach { (email) in
let matches = regex.matches(in: email, options: [], range: NSRange(location: 0, length: email.count))
var initials = ""
for m in matches {
let firstChar = m.range(at: 1)
@whiskey
whiskey / buildPhases.sh
Created December 7, 2015 15:39
Auto set build number (CFBundleVersion) via the current number of git commits in your actual branch
###### one of the first build phases
#Update build number with number of git commits if in release mode
buildNumber=$(git rev-list HEAD | wc -l | tr -d ' ')
flag=""
if [ ! ${CONFIGURATION} == "Release" ]; then
flag="b"
fi;
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber$flag" "${INFOPLIST_FILE}"
enum FormSection: Int {
case Header, Section1, Section2, Section2, Section3, Summary
static let identifiers = [
Header: "header",
Section1: "s1",
Section2: "s2",
Section3: "s3",
Summary: "summary"
]
@whiskey
whiskey / LocalizedLanguages.swift
Last active August 29, 2015 14:10
display languages names translated by the device language
// Playground - noun: a place where people can play
import Foundation
// an example list of device languages
let deviceLocales = ["DE", "GB", "SE", "no_NB", "DA", "FR", "PL", "MK"]
// this comes from the APIs city list
let countryCodes = ["DE", "GB", "US", "SE", "DK", "JP"]
@whiskey
whiskey / main.m
Last active December 22, 2015 21:49
POSIX my ASS!
//
// main.m
// POSIXmyAss
//
// Created by Carsten Witzke on 12.09.13.
//
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])