Skip to content

Instantly share code, notes, and snippets.

@bleft
bleft / docker-compose.yml
Created February 17, 2022 07:21
Run Wordpress with MySQL in Docker - start with: docker-compose up -d
version: "3.8"
services:
db:
image: mysql:latest
volumes:
- ./db/data:/var/lib/mysql
ports:
- "3306:3306"
restart: always
@bleft
bleft / MySQL.sql
Last active November 12, 2019 12:07
SELECT DATE_FORMAT(FROM_UNIXTIME(`date`), '%e %b %Y %H:%m:%s') AS created, temp, humid FROM `table_name` ORDER BY id DESC LIMIT 1;
@bleft
bleft / AppList.md
Created May 13, 2019 12:32
Software for new Macs

Software for new Macs

  • 1Password
  • Xcode
  • bear
  • homebrew
  • intelliJ IDEA
  • iXLIFF
  • Tweetbot
  • TextMate
  • Gimp
@bleft
bleft / string+extenstion.swift
Created February 28, 2019 12:20
check for valid email
extension String {
var isValidEmail: Bool {
let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx)
return emailTest.evaluate(with: self)
}
}
@bleft
bleft / GradientView.swift
Last active January 19, 2018 13:09
UIView with CAGradient
class MyView: UIView {
private let gradient = CAGradientLayer()
override func draw(_ rect: CGRect) {
super.draw(rect)
gradient.colors = [UIColor.red.cgColor, UIColor.blue.cgColor] // beliebig viele Farben für den Verlauf einstellen
gradient.startPoint = CGPoint(x: 0, y: 0) // über start und endPoint kann die Richtung des Verlaufes verändert werden.
gradient.endPoint = CGPoint(x: 0, y: 1)
@bleft
bleft / checkIP.sh
Created December 12, 2017 10:06
check server IP from outside
wget -qO- http://checkip.dyndns.org | sed -e 's/^.*s: //' -e 's_</b.*$__'
@bleft
bleft / UIButton+Extension.swift
Last active March 12, 2021 19:04
UIButton with centered Image and Text
// with the help of: https://gist.github.com/phpmaple/9458264
extension UIButton {
func centerImageAndButton(_ gap: CGFloat, imageOnTop: Bool) {
guard let imageView = self.imageView,
let titleLabel = self.titleLabel else { return }
let sign: CGFloat = imageOnTop ? 1 : -1;
let imageSize = imageView.frame.size;
@bleft
bleft / monogdb.js
Created April 28, 2017 12:56
mongo-helper
// find duplicates
db.collection.aggregate([
{ $group: {
_id: { firstField: "$firstField", secondField: "$secondField" },
uniqueIds: { $addToSet: "$_id" },
count: { $sum: 1 }
}},
{ $match: {
count: { $gt: 1 }
}}
@bleft
bleft / tar.sh
Created April 11, 2017 14:08
create and extract tar archives
# create archive
# c: create v: verbose f: output file
tar -cvf target.tar /folder
# zipped:
tar -czvf target.tar.gz /folder
# extract archive to
# folder must exist!
tar -zxvf target.tar.gz -C /folder
@bleft
bleft / customErrors.swift
Last active April 29, 2020 12:32
custom enum errors with localizedDescription
// sepcifiy your errors
enum MyCustomError : Error {
case customError
case missingProperty
var localizedDescription: String {
switch self {
case .urlCouldNotBeCreated:
return NSLocalizedString("MyCustomErrorCcustomError", value: "a localized error message", comment: "")
case .missingProperty: