Skip to content

Instantly share code, notes, and snippets.

View xremix's full-sized avatar
👨‍💻

Toni Hoffmann xremix

👨‍💻
View GitHub Profile
@xremix
xremix / swiftui-alerts.swift
Created April 2, 2023 12:53
Alerts in SwiftUI
struct ContentView: View {
@State private var presentAlert = false
@State private var username: String = ""
@State private var password: String = ""
var body: some View {
Button("Show Alert") {
presentAlert = true
}
.alert("Login", isPresented: $presentAlert, actions: {
@xremix
xremix / automated-app-install.sh
Last active March 14, 2023 10:33
Automated App Install
#!/bin/sh
## Thanks to https://gist.github.com/tscheckenbach/00f1ae57881b79254f11f1815debd9af
echo "Please login to your Apple Account through the Mac App Store"
echo "When logged in sucessfully press [ENTER} to continue"
read
##############################################
## Install homebrew and Xcode
@xremix
xremix / List-All-Secrets-Key-Vault.ps1
Last active March 24, 2020 08:49
List all Secrets of a Key Vault
# Run & ./List-All-Secrets-Key-Vault.ps1 my-vault-name
param([string]$KeyVaultName)
$secrets = Get-AzureKeyVaultSecret -VaultName $KeyVaultName
$secrets.foreach{ Get-AzureKeyVaultSecret -VaultName $_.VaultName -Name $_.Name } | Select-Object Name,SecretValueText
@xremix
xremix / humanReadableInterval.swift
Created April 3, 2018 11:40
Swift 3 human-readable Date Interval
class HumanTimeInterval{
// inspired by https://gist.github.com/skreutzberger/9122ac3683f3354a7e24
static func relativeDateInterval(date: Date) -> String? {
let formatter = DateComponentsFormatter()
formatter.unitsStyle = .abbreviated
formatter.includesApproximationPhrase = false
formatter.includesTimeRemainingPhrase = false
formatter.allowedUnits = [.year, .month, .weekOfMonth, .day, .hour, .minute, .second]
formatter.maximumUnitCount = 2
@xremix
xremix / lines-of-code-regex
Created March 20, 2018 10:39
Lines of Code of a Software Project for Sublime
^.*\S+.*$
@xremix
xremix / perl.pl
Last active April 11, 2018 17:18
Perl cheat sheet
#!/usr/bin/perl
# ^ wird verwendet wenn mehrere Perl installiert
use Math::Trig; # Mathe Library
# spitze klammern sind Handle
chomp($r = <STDIN>); # Zeile einlesen
# chomp Entfernt alle strings die noch aus der vorherigen eingeabe vorhanden sind
print 2 * pi * $r;
@xremix
xremix / first-notnil-property.swift
Created January 16, 2018 08:22
First not nil Property
import UIKit
class MyObjects: NSObject{
var myOptional: String?
var myRequired: String
init(req: String, op: String?) {
myOptional = op
myRequired = req
}
}
@xremix
xremix / file-executable.sh
Created January 14, 2018 13:35
Unix make file executable
# Simple code to give a file executable rights
chmod u+x file.sh
@xremix
xremix / continous-shell-tcp-listener.sh
Last active January 8, 2018 12:22
Shell TCP Listener
#!/bin/bash
#Make Sure Script Is Ran As Root
if [ $(id -u) != 0 ]; then
echo; echo -e "\e[1;31mScript must be run as sudo. Please Type \"sudo\" To Run As Root \e[0m"; echo
exit 1
fi
echo "Enter port to listen"
read portL
@xremix
xremix / README.md
Created January 5, 2018 09:33
MemBlower

Memblower

ATTENTION! This is just for testing purposes. The two files try different approaches to store endless data in the memory. This experiment shows how the computer behaves in edge cases.