Skip to content

Instantly share code, notes, and snippets.

View alldne's full-sized avatar

jojo alldne

View GitHub Profile
@alldne
alldne / test.json
Created March 16, 2022 09:46
test.json
{
"ABCD": 3.234E9,
"DEFG": 1.232
}
@alldne
alldne / resize-icon.bash
Created March 30, 2021 09:32
resize-icon.bash
#!/bin/bash
# https://stackoverflow.com/a/51343786
# https://developer.apple.com/library/archive/qa/qa1686/_index.html
RED='\033[0;31m' # Red
GREEN='\033[0;32m' # Green
RESET='\033[0m' # Text Reset
function __system {
echo -e $GREEN$*$RESET
@alldne
alldne / distinctUntilChangedInGroup.swift
Created July 16, 2020 06:57
distinctUntilChangedInGroup
extension ObservableType {
/**
Returns an observable sequence that contains only distinct contiguous elements in a virtual group by key.
For example,
Original stream:
(A, 1), (A, 2), (B, 100), (A, 2), (A, 2), (B, 101), (A, 3)
distinctUntilChanged
@alldne
alldne / UIScrollView+loadMore.swift
Created March 28, 2020 16:56
RxSwift UIScrollView loadMore
extension Reactive where Base: UIScrollView {
var loadMore: Observable<Void> {
return contentOffset
.map({ [weak base] (offset) in
guard let scrollView = base else { return false }
return offset.y + scrollView.bounds.size.height - scrollView.adjustedContentInset.bottom >= scrollView.contentSize.height
})
.distinctUntilChanged()
.filter({ $0 })
.mapTo(Void())
@alldne
alldne / match_and_disable_automatic_code_signing.rb
Last active March 26, 2020 04:10
[Fastlane] match and disable automatic code signing
private_lane :match_and_disable_automatic_code_signing do |options|
# https://github.com/fastlane/fastlane/issues/1187#issuecomment-174074360
bundle_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
match(options)
provisioning_map = lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING]
automatic_code_signing(
use_automatic_signing: false,
@alldne
alldne / ContentSizeView.swift
Created February 22, 2020 20:23
ContentSizeView.swift
class ContentSizeView: UIView {
override var intrinsicContentSize: CGSize {
return contentSize ?? CGSize(width: UIView.noIntrinsicMetric, height: UIView.noIntrinsicMetric)
}
var contentSize: CGSize? {
didSet {
invalidateIntrinsicContentSize()
}
}
@alldne
alldne / parse-git-log-numstat.py
Last active January 5, 2020 04:08
parse-git-log-numstat.py
#!/usr/bin/env python3
import sys
import os
import fileinput
from collections import Counter
def main():
n = None
if len(sys.argv) > 1:
@alldne
alldne / save.sh
Created October 25, 2019 18:03
Commit all the changes from tracked files
# Fire alarm!!
alias save='git commit -a -m "saved `date`"'
@alldne
alldne / characters-in-characterset.md
Last active May 8, 2019 09:01
Characters in CharacterSet for URL encoding

Characters in CharacterSet for URL encoding

fragment
["!", "$", "&", "\'", "(", ")", "*", "+", ",", "-", ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "=", "?", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "_", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "~"]

host
["!", "$", "&", "\'", "(", ")", "*", "+", ",", "-", ".", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "=", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "]", "_", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "~"]
@alldne
alldne / Array+ObserverType.swift
Last active September 11, 2019 15:24
[RxCocoa] Use `bind(to:)` on an array of `ObserverType`
extension Array: ObserverType where Element: ObserverType {
public typealias E = Element.E
public func on(_ event: Event<E>) {
forEach { (element) in
element.on(event)
}
}
}