Skip to content

Instantly share code, notes, and snippets.

View eiskalteschatten's full-sized avatar

Alex Seifert eiskalteschatten

View GitHub Profile
@eiskalteschatten
eiskalteschatten / gist:6390600
Created August 30, 2013 14:43
Automatic Firefox detection in CSS
@-moz-document url-prefix() {
.css-class {
}
}
@eiskalteschatten
eiskalteschatten / ImageResizer.swift
Last active January 24, 2024 15:58
A function written in Swift to resize an NSImage proportionately
//
// ImageResizer.swift
//
// Created by Alex Seifert on 18/06/2016.
// http://www.alexseifert.com
//
import Foundation
import Cocoa
@eiskalteschatten
eiskalteschatten / update-wordpress.sh
Created October 2, 2016 12:37
Update WordPress with a Bash script using WP CLI
#!/bin/bash
function updateWordPress {
cd $1
wp core update
wait
wp plugin update --all
wait
wp theme update --all
wait
@eiskalteschatten
eiskalteschatten / convert-indendations.sh
Last active July 14, 2018 07:16
Batch Convert 4-Space Indentations to 2-Space
#!/bin/bash
expand_func () {
OLD_LENGTH=4 # old indentation length
NEW_LENGTH=2 # new indentation length
unexpand -t $OLD_LENGTH "$1" | expand -t $NEW_LENGTH > "$1.tmp"
mv "$1.tmp" "$1"
}
export -f expand_func
@eiskalteschatten
eiskalteschatten / responsive.ts
Created May 31, 2020 13:22
A small script to determine viewport widths based on Bootstrap breakpoints.
// View port widths from Bootstrap
export const xs = 0;
export const sm = 576;
export const md = 768;
export const lg = 992;
export const xl = 1200;
export const vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
export const isSmDown = (): boolean => vw <= sm;
export const isMdDown = (): boolean => vw <= md;
@eiskalteschatten
eiskalteschatten / iPadorIPhone.swift
Created April 24, 2022 11:15
This is a simple if-else statement to determine whether an iOS device is an iPad or iPhone
if UIDevice.current.userInterfaceIdiom == .pad {
// iPad
}
else {
// iPhone
}
@eiskalteschatten
eiskalteschatten / ShowAllThreeColumns.swift
Created May 1, 2022 11:42
Example code showing how to show all three columns of a SwiftUI NavigationView by default on iPad
extension UISplitViewController {
open override func viewDidLoad() {
super.viewDidLoad()
self.show(.primary)
}
}
@eiskalteschatten
eiskalteschatten / generateKey.sh
Created May 9, 2022 10:01
Generate a Secret or Key in the Command Line with Node.js
#!/bin/sh
node -e "console.log(require('crypto').randomBytes(256).toString('base64'));