Skip to content

Instantly share code, notes, and snippets.

View strike65's full-sized avatar

VT strike65

  • Nope
  • Earth, Altitude 20 cm
View GitHub Profile
@strike65
strike65 / deployment_guide.md
Created September 1, 2019 10:31 — forked from vicgonvt/deployment_guide.md
Deployment Guide for Ubuntu Server from Scratch with Laravel
@strike65
strike65 / update_app
Created August 28, 2019 16:47
Deploy an Laravel App the "save" way
#!/bin/bash
cd /path/to/app
sudo chown -R githubuser:githubuser /path/to/app
php artisan down
git fetch && git reset --hard origin/master
cat << EOF > .env
APP_NAME=APP_NAME
APP_ENV=production
APP_KEY=<YOUR KEY>
APP_DEBUG=false
@strike65
strike65 / Predictable Network InterfaceNames.md
Created August 11, 2019 12:21 — forked from bbak/Predictable Network InterfaceNames.md
Debian 9 / Stretch: Umstellung auf Predictable Network InterfaceNames

Warnung an alle, die dieses Gist finden: Ich habe hier nur dokumentiert, was ich im Rahmen einer Umstellung herausgefunden habe. Es gibt Garantie auf Richtigkeit der Informationen, Zusammenhänge oder ob das unter allen Umständen wie hier beschrieben funktioniert.

Predictable Network InterfaceNames

Debian stellt auf ein anderes System von Namen für Netzwerkinterfaces um. In Debian 9 gehen noch die alten, manuell festgelegten - was der Standard ist, wenn man von Debian 8 aktualisiert.
Ab Debian 10 wird dieses System, welches mit udev und systemd zusammen hängt, zum Standard.

Mit zless /usr/share/doc/udev/README.Debian.gz kann man Debian-spezifische Informationen zu dem Thema finden.
Unter anderem auch, dass (und wie) man diesen Mechanismus in Debian 9 Stretch umgehen kann.

/// Add Codable protocol conformance to Float80
extension Float80: Codable {
private enum CodingKeys: String, CodingKey {
case string = "stringValue"
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
let stringRep: String = "\(self)"
try container.encode(stringRep, forKey: .string)
}
@strike65
strike65 / Extension-Array-indices.swift
Created June 10, 2019 11:20
Extension for Swift Array Type: indices(where:)
/// Returns an array of indexes for which the condition is true.
///
/// ````
/// let A = [1,2,3,2,1,3]
/// var indices = A.indices(where: { $0 == 1 })
/// // [0, 4]
/// indices = A.indices(where: { $0 == 3 })
/// // [2, 5]
/// indices = A.indices(where: {(x: Int) -> Bool in
/// return x == 1
@strike65
strike65 / FloatingPoint-MathConstants.swift
Last active October 2, 2018 09:59
Extension of the Swift FloatingPoint Protocol (math constants)
/// Extends the FloatingPoint Protocol by adding important constants
public protocol SSFloatingPoint: FloatingPoint {
/// 0
static var zero: Self { get }
/// 1
static var one: Self { get }
/// 1 / 2
static var half: Self { get }
@strike65
strike65 / Swift5StateOfString.md
Created July 14, 2018 19:58 — forked from milseman/Swift5StateOfString.md
State of String: ABI, Performance, Ergonomics, and You!

State of String: ABI, Performance, Ergonomics, and You!

Hello, I’ve been working on implementing, optimizing, and improving String in preparation for ABI stability, and I thought I’d share the current status of String in Swift 5 and some potential directions to go. This is the product of conversations with open source contributors and my colleagues on the Swift standard library team at Apple.

The primary area of focus is stabilizing String’s ABI, but we’d be remiss if we couldn’t also fit in performance and ergonomic improvements. String’s ergonomics in particular is one area where we think the status quo is woefully inadequate, and over half of this email is devoted to that topic. At the end, there’s a section about a community initiative that we hope can help users of String as well as guide future development.

(Note: I’m sending this to swift-dev because much of the contents revolve around implementation concerns. I’ll also cross-reference on swift-evolution and swift-users. See also the [StringManife

@strike65
strike65 / InvalidCharacters.swift
Created May 18, 2018 17:08
Returns true, iff string contains any of the characters in invalidCharacters
import Foundation
func hasInvalidCharacters(_ string: String!, invalidCharacters: String = "_*#+") -> Bool {
let invalidCharacters: CharacterSet = CharacterSet.init(charactersIn: invalidCharacters)
let range = string.rangeOfCharacter(from: invalidCharacters, options: .literal)
if range != nil {
return true
}
else {
return false
@strike65
strike65 / fibonacci.swift
Created May 18, 2018 17:01
Computes the n_th Fibonacci number
import Foundation
func fibonacci(n: Int) -> Double {
let oneOverTwoSqrt5 = 1.0 / (2.0 * sqrt(5))
let sqrt5OverTwo = sqrt(5) / 2.0
let a = 1.0 / 2.0 + oneOverTwoSqrt5
let b = 1.0 / 2.0 - oneOverTwoSqrt5
let f = a * pow(0.5 + sqrt5OverTwo, Double(n) - 1.0) + b * pow(0.5 - sqrt5OverTwo, Double(n) - 1.0)
return round(f)
}