Skip to content

Instantly share code, notes, and snippets.

@supermarin
supermarin / .env
Last active April 2, 2024 13:57
Colored `man` pages on OSX
# ZSH / BASH users
# Add this to your .env, .bashrc, .zshrc, or whatever file you're using for environment
man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
@supermarin
supermarin / combine-throttle-bug.swift
Created February 3, 2020 14:48
Smallest reproduction of Combine's throttle() timing bug
// Bug initially observed when throttling a frequent signal out of a socket.
// When throttled to .seconds(1), there were around 50 ticks in a 60 second interval.
//
// This example eliminates the frequent source and just uses a 1-second timer,
// throttled by a 1-seconds throttle function.
//
// Expected behavior: 60 ticks in a minute
// Acutal behavior: ~33 ticks in a minute
import Combine
import Foundation
@supermarin
supermarin / dash_emoji_snippets.sql
Last active January 30, 2020 19:58
Emoji in realtime with Dash.app Thanks @orta for putting this up. Read below for importing instructions
INSERT INTO 'snippets' ('title', 'body') VALUES
(':+1:', '👍'),
(':-1:', '👎'),
(':100:', '💯'),
(':1234:', '🔢'),
(':8ball:', '🎱'),
(':a:', '🅰'),
(':ab:', '🆎'),
(':abc:', '🔤'),
(':abcd:', '🔡'),
Incident Identifier: D27A2F5A-9A2D-4470-9E21-1482AE1949E0
CrashReporter Key: 5198ebb12a2742430c65705de40ce9a9c18a70cc
Hardware Model: iPhone11,2
Process: Hello [17272]
Path: /private/var/containers/Bundle/Application/8EC26856-2582-4E2F-9C82-F213FF98CC3F/Hello.app/Hello
Identifier: com.hello.ios
Version: 3 (0.1)
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
@supermarin
supermarin / snippet.m
Created October 23, 2018 20:17
fetching cached configuration using dispatch groups and early return
@interface ViewController ()
@end
@implementation ViewController
static dispatch_queue_t serialq;
static dispatch_queue_t concurrentq;
- (void)getConfigurationWithCompletion:(void (^)(NSString *))completionBlock {
static NSString *configuration;
@supermarin
supermarin / NSStringLiterals.m
Created December 5, 2012 22:14
NSString literals
// Currently, there's too much effort for printing strings with arguments.
// The current way
NSString *sentence = [NSString stringWithFormat:@"This is a text with argument %@", argument];
// Possible literal
NSString *sentence = @("This is a text with argument %@", argument);
@supermarin
supermarin / unfuck.conf
Created April 17, 2014 22:20
Tmux defaults that everyone should have in
# unfuck the terminal colors
set -g default-terminal "screen-256color"
# unfuck the Esc
set -s escape-time 0
# unfuck mouse scrolling
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
# unfuck copy and paste
@supermarin
supermarin / delete-contacts.swift
Last active March 22, 2016 07:40
Delete useless contacts from your address book
//
// main.swift
// deleteshit
//
// Created by Marin Usalj on 3/21/16.
// Copyright © 2016 supermar.in. All rights reserved.
//
import Foundation
import AddressBook
@supermarin
supermarin / gist:5983009
Last active December 19, 2015 16:19 — forked from alloy/gist:5982920

Open-source logo licensing

Our open-source project (CocoaPods) has a logo drawn by a commissioned designer (@maxsteenbergen). Basically, we want Max Steenbergen to retain his copyright over the logo, but give us (CocoaPods) an exclusive license to do what we want, as described below.

We want our users to:

  1. BE ABLE to use the logo AS-IS for CocoaPods promotional purposes. Some examples are:
  • In a blog post about (amongst others) CocoaPods.
  • On the website of a commercial continuos-integration platform, to indicate they support CocoaPods projects.
  • Sell (i.e. commercial) stickers/t-shirts/mugs etc with the logo on it.
@supermarin
supermarin / wo.fish
Created June 10, 2013 16:31
Quickly move from / to project directories in Fish shell
# Search through my code directories and quickly open project folder
# wo = workon
function wo
set -l code_dir ~/code
cd (find $code_dir -type d -maxdepth 3 | grep -i $argv | grep -Ev Pods --max-count=1)
end