Skip to content

Instantly share code, notes, and snippets.

@simme
simme / Install_tmux
Created October 19, 2011 07:55
Install and configure tmux on Mac OS X
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
@simme
simme / UITabBarController+ToggleTabBar.swift
Created January 25, 2018 15:36
Extension on UITabBarController for hiding/showing the tab bar.
extension UITabBarController {
/**
Show or hide the tab bar.
- Parameter hidden: `true` if the bar should be hidden.
- Parameter animated: `true` if the action should be animated.
- Parameter transitionCoordinator: An optional `UIViewControllerTransitionCoordinator` to perform the animation
along side with. For example during a push on a `UINavigationController`.
*/
/*
Usage:
Store(
initialState: .init(),
reducer: UserRecipesListReducer().relay { [unowned self] featureAction in
// Handle action here
}
)
*/
@simme
simme / StoreControllerDialogs.swift
Created April 4, 2023 08:44
UIKit helpers for presenting alerts and confirmation dialogs
/*
Example usage:
confirmationDialog(
store: store.scope(state: \.destination, action: UserRecipesListReducer.Action.destination),
state: /UserRecipesListReducer.Destination.State.confirmation,
action: UserRecipesListReducer.Destination.Action.confirmation
).store(in: &subscriptions)
alert(
@simme
simme / debounce-throttle.swift
Created December 20, 2016 10:04
Swift 3 debounce & throttle
//
// debounce-throttle.swift
//
// Created by Simon Ljungberg on 19/12/16.
// License: MIT
//
import Foundation
extension TimeInterval {
import CloudKit
import Combine
/// A publisher that wraps a `CKFetchRecordZoneChangesOperation` and emits events as the operation completes.
///
/// The `FetchRecordZoneChangesPublisher` fetches changes from the given record zones. New and deleted records are
/// posted individually via the `.recordChanged` and `.recordDeleted` actions.
///
/// Errors are automatically retried if possible. Resetting the change token in case it expired is also automatically
/// handled. Because emitting errors fails a publisher all errors are posted as actions. There may still be running
@simme
simme / UNNotification+Reschdule.swift
Created November 17, 2016 09:43
Exntension to `UNNotification` for "snoozing" a notification.
//
// UNNotification+Reschedule.swift
// Meal Plan
//
// Created by Simon Ljungberg on 17/11/16.
// License: MIT
//
import UIKit
import UserNotifications
@simme
simme / Label.swift
Created May 16, 2018 09:09
A `UILabel` subclass that allows content padding.
// MIT License applies.
import UIKit
/**
A `UILabel` subclass that provides a way of adding padding to the label.
*/
open class Label: UILabel {
/// The amount of padding for each side in the label.

Given these two tables

lists

id name weight
1 Groceries 0
2 Pharmacy 1
3 Misc 2
@simme
simme / Base64Image.php
Created December 30, 2010 09:57
Returns the Base64 encoded version of an image. Has basic support for Drupal module ImageCache. Does not depend on Drupal.
<?php
/**
* @file
* Helper class for encoding images as Base64.
* Has support for the Drupal module ImageCache, just provide it with your
* preset name if you'd like the class to use that version of an image instead.
* Is by no means dependent on Drupal though. Just a nice feature.
* Feel free to use it as you like.
*
* @author Simon Ljungberg <simon@nimnim.se>