Skip to content

Instantly share code, notes, and snippets.

View elmodos's full-sized avatar
🇺🇦

Modo Ltunzher elmodos

🇺🇦
View GitHub Profile
@elmodos
elmodos / Locale+FlagEmoji.swift
Created November 6, 2022 18:06
Locale to country flag emoji
extension Locale {
var flagEmoji: String? {
let base: UInt32 = 127397
return countryCode?
.unicodeScalars
.compactMap { Unicode.Scalar(base + $0.value) }
.reduce("", { $0.appending(String($1)) } )
}
}
@elmodos
elmodos / .gitconfig
Created December 17, 2021 22:05
GitHub with multiple repos and usernames on single machine
~/.gitconfig
[user]
name = Personal Name
email = personal@email.com
[includeif "gitdir:~/Projects/Company/"]
path = Projects/Company/gitconfig-company
@elmodos
elmodos / SimplePromise.swift
Last active October 19, 2021 19:00
Quick promise implemention
import Foundation
public class Promise<T> {
public private(set) lazy var future: Future<T> = Future()
public init() { /**/ }
public func fulfill(_ value: T) {
future.result = .success(value)
@elmodos
elmodos / DynamicContentTransitioner.swift
Last active November 12, 2019 15:07
iOS UIViewController modal Interactive dismisser
import UIKit
public protocol DynamicContentTransitinable {
func layoutContentOnscreen()
func layoutContentOffscreen()
}
public class DynamicContentTransitioner: NSObject, UIViewControllerAnimatedTransitioning {
var animationDuration: TimeInterval
@elmodos
elmodos / String+HtmlTags.swift
Created July 4, 2019 10:40
Swift: strip String from HTML tags
public extension String {
func htmlTagsStripped() -> String? {
let stripped = self
.flattenHtml()
.trimmingCharacters(in: .whitespacesAndNewlines)
.removingLinebreaks()
.removingMultipleSpaces()
.replacingHtmlCharEntities()
return stripped
import UIKit
open class ZoomImageView: UIScrollView, UIScrollViewDelegate {
// MARK: Publics
public enum ZoomMode {
case fit
case fill
#!/bin/sh
PS3='Type the number of your choice (1, 2 or 3) and press Enter: '
options=("List Devices" "Run Simulator" "Quit")
select opt in "${options[@]}"
do
case $opt in
"List Devices")
xcrun simctl list devices
echo "\033[1m\n\nCopy the UDID in parentheses of the device which you want run and launch option 2 (Run Simulator)\033[0m"
;;
@elmodos
elmodos / dropbox.sh
Created November 24, 2016 20:01
Launch dropbox in xfce, tray icon fix
#!/bin/bash
dbus-launch dropbox start -i
@elmodos
elmodos / ValidateRenewablePurchases.m
Last active December 6, 2016 12:58
Check iOS auto-renewable subscriptions if they are still valid
- (void)validateRenewablePurchases:(NSArray<NSString *> *)products callback:(void (^)(NSDictionary *values, NSString *errorMessage))callback
{
// Sending into background
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ @autoreleasepool{
void (^callbackOnMainThread)(NSDictionary *values, NSString *errorMessage) = ^(NSDictionary *values, NSString *errorMessage) {
dispatch_async(dispatch_get_main_queue(), ^{
callback(values, errorMessage);
});
};
@elmodos
elmodos / viber.desktop
Created October 23, 2016 21:59
Viber linux show correct tray icon
[Desktop Entry]
Name=Viber
Comment=Viber VoIP and messenger
Exec=env XDG_CURRENT_DESKTOP=Unity /opt/viber/Viber
Icon=/usr/share/pixmaps/viber.png
Terminal=false
Type=Application
Encoding=UTF-8
Categories=Network;Application;
Path=