Skip to content

Instantly share code, notes, and snippets.

@Amzd
Amzd / UIStatusBarManager+statusBarTappedNotification.swift
Last active March 16, 2026 20:39
Detect taps in status bar on iOS 13+. Confirmed to work on iOS 26
import UIKit
/// https://gist.github.com/Amzd/c3171021488fc82d1b68cfd8e89ada7b
extension UIStatusBarManager {
public static var statusBarTappedNotification: Notification.Name = {
if let originalMethod = class_getInstanceMethod(UIStatusBarManager.self, Selector(("handleTapAction:"))),
let swizzledMethod = class_getInstanceMethod(UIStatusBarManager.self, #selector(_handleTapAction)),
// Prevent crash in case an argument is added/removed in the future
method_getNumberOfArguments(originalMethod) == method_getNumberOfArguments(swizzledMethod) {
method_exchangeImplementations(originalMethod, swizzledMethod)
@hristogochev
hristogochev / VoyagerSystemBars.kt
Created September 15, 2024 19:36
Voyager system bars workaround
// You can invoke LocalSystemBarsWindowInsets.current to get the correct window insets.
// You may need to pass this as a parameter to Scaffold if you use it, luckily Scaffold accepts custom WindowInsets.
val LocalSystemBarsWindowInsets = compositionLocalOf { WindowInsets(0.dp, 0.dp, 0.dp, 0.dp) }
// Wrap your main App function call with this one to access the system bars everywhere
@Composable
fun WithVoyagerSystemBars(content: @Composable () -> Unit) {
val systemBarsWindowInsets = WindowInsets.systemBars
CompositionLocalProvider(LocalSystemBarsWindowInsets provides systemBarsWindowInsets) {
@bhrott
bhrott / FuckingSubstringSwift3.md
Last active December 30, 2018 00:34
Fucking substring Swift 3

1 - Create a extensions for String with a new, wonderfull, superpower method called crop:

extension String {
    func crop(from: Int, length: Int) -> String! {
        let startIndex = self.index(self.startIndex, offsetBy: from)
        
        var result = self.substring(from: startIndex)
        
        let endIndex = result.index(result.startIndex, offsetBy: length)
 result = result.substring(to: endIndex)
@bulwinkel
bulwinkel / mapToBundle.kt
Created January 7, 2017 13:35
Partial implementation of converting a `Map<String, V>` to a Bundle.
package com.bulwinkel.android
import android.os.Bundle
import android.os.IBinder
import android.os.Parcelable
import java.io.Serializable
fun <V> Map<String, V>.toBundle(bundle: Bundle = Bundle()): Bundle = bundle.apply {
forEach {
val k = it.key
@Bhavdip
Bhavdip / sketch-never-ending.md
Created October 6, 2016 15:53
Modify Sketch to never ending trial

###Sketch trial non stop

Open hosts files:

$ open /private/etc/hosts

Edit the file adding:

127.0.0.1 backend.bohemiancoding.com

127.0.0.1 bohemiancoding.sketch.analytics.s3-website-us-east-1.amazonaws.com

@lukaspili
lukaspili / ScrollableViewController.swift
Last active March 17, 2023 12:35
Scroll view snap kit
import UIKit
import SnapKit
class ScrollableViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor.whiteColor()
let scrollView = UIScrollView()
@BR0kEN-
BR0kEN- / string_functions.sh
Created June 8, 2015 11:25
Bash implementation of strpos and substr functions from PHP library
#!/usr/bin/env bash
# @param string $1
# Input string.
# @param int $2
# Cut an amount of characters from left side of string.
# @param int [$3]
# Leave an amount of characters in the truncated string.
substr()
{
@GaryJones
GaryJones / RedirectsCept.php
Last active May 20, 2019 15:21
Codeception 301 Redirection Tests
<?php
$I = new RedirectsTester($scenario);
$I->wantTo('check 301 redirects are working');
// First, test /login/ page gets rewritten to https://
$I->seePermanentRedirectToHttpsFor('login/');
$I->seePermanentRedirectToHttpsFor('login/?redirect_to=foo');
@cyrilmottier
cyrilmottier / ResourcesAdditions.java
Last active January 12, 2024 17:55
Lightweight key-value pairs resources for Android applications.
package com.cyrilmottier.android.resourcesadditions;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.os.Bundle;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/**
* @author Cyril Mottier
@eusonlito
eusonlito / foldersize.php
Last active March 11, 2025 07:56
PHP function to get the folder size including subfolders
<?php
function folderSize ($dir)
{
$size = 0;
foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) {
$size += is_file($each) ? filesize($each) : folderSize($each);
}