Skip to content

Instantly share code, notes, and snippets.

View fabiosoft's full-sized avatar

Fabio Nisci fabiosoft

View GitHub Profile
@jaredmales
jaredmales / rclone-cron.sh
Last active January 8, 2024 01:56
An rclone backup script for cron
#!/bin/bash
##############################################################################
# An rclone backup script by Jared Males (jaredmales@gmail.com)
#
# Copyright (C) 2018 Jared Males <jaredmales@gmail.com>
#
# This script is licensed under the terms of the MIT license.
# https://opensource.org/licenses/MIT
#
@srosenthal
srosenthal / gist:3adc0dafcdd3c55656bad7a4a8de9c91
Created December 17, 2017 20:40
Batch convert HEIC (iPhone) photos to JPEG, preserving creation dates
for i in *.heic; do sips -s format jpeg -s formatOptions best "${i}" --out "${i%heic}jpg" && touch -r "${i}" "${i%heic}jpg"; done
@kevinswiber
kevinswiber / backends.js
Last active February 6, 2024 18:56
Express Gateway Example with Multiple Services
const express = require('express');
const forum = express();
forum
.get('/healthz', (req, res, next) => {
res.send({ name: 'forum', status: 'healthy' });
next();
})
.get('/d/:id', (req, res, next) => {
@DejanEnspyra
DejanEnspyra / Obfuscator.swift
Created May 31, 2017 17:51
Obfuscation of hard-coded security-sensitive strings.
//
// Obfuscator.swift
//
// Created by Dejan Atanasov on 2017-05-31.
//
import Foundation
class Obfuscator: AnyObject {
@saoudrizwan
saoudrizwan / TouchUpInsideViews.swift
Last active October 29, 2023 14:16
Using a long press gesture recognizer, you can recreate a 'touch up inside' button effect on any view.
let longPress = UILongPressGestureRecognizer(target: self, action: #selector(upgradeAlertViewOtherUpgradesLongPressHandler))
longPress.minimumPressDuration = 0
var longPressGRStartPoint: CGPoint?
var didCancelLongPressGR = false
func viewTouched(sender: UILongPressGestureRecognizer) {
let currentPoint = sender.location(in: self.view)
switch sender.state {
case .began:
@stevenojo
stevenojo / ObjectiveCDebounce.md
Last active May 6, 2023 23:56
Objective-C Debounce Example Using GCD Dispatch Sources / Timer

##Debouncing using GCD on iOS

The idea of "Debouncing" is to limit the rate a function or task can execute by waiting a certain amount of time before executing it. In the example below, if a user rapidly enters input, it will only execute once, 1 second after all that input. This is the implementation of a sample class showing how to do so, while using Grand Central Dispatch to create a timer. The timer fires on a global queue in this example - but you can change the queue to any queue where you want the timer to execute, regardless of where you set it up.

#import <Foundation/Foundation.h>

@interface DebounceExample : NSObject
@soffes
soffes / UISplitViewController+Soffes.swift
Created June 8, 2016 22:23
Easily access master and detail view controllers on UISplitViewController
import UIKit
extension UISplitViewController {
convenience init(masterViewController: UIViewController, detailViewController: UIViewController) {
self.init()
viewControllers = [masterViewController, detailViewController]
}
var masterViewController: UIViewController? {
return viewControllers.first
@obfusk
obfusk / repl.py
Created May 27, 2016 23:50
python repl example
#!/usr/bin/python
from __future__ import print_function
import sys
if sys.version_info.major == 2:
def prompt(s = ">>> "): return raw_input(s)
else:
def prompt(s = ">>> "): return input(s)
@mourad-brahim
mourad-brahim / UIView+Animations.swift
Last active December 1, 2022 07:29
Shake animation with swift
extension UIView {
func shake(duration: CFTimeInterval) {
let translation = CAKeyframeAnimation(keyPath: "transform.translation.x");
translation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
translation.values = [-5, 5, -5, 5, -3, 3, -2, 2, 0]
let rotation = CAKeyframeAnimation(keyPath: "transform.rotation.z")
rotation.values = [-5, 5, -5, 5, -3, 3, -2, 2, 0].map {
(let degrees: Double) -> Double in
let radians: Double = (M_PI * degrees) / 180.0
@zacwest
zacwest / ios-font-sizes.swift
Last active May 6, 2024 13:04
iOS default font sizes - also available on https://www.iosfontsizes.com
let styles: [UIFont.TextStyle] = [
// iOS 17
.extraLargeTitle, .extraLargeTitle2,
// iOS 11
.largeTitle,
// iOS 9
.title1, .title2, .title3, .callout,
// iOS 7
.headline, .subheadline, .body, .footnote, .caption1, .caption2,
]