Skip to content

Instantly share code, notes, and snippets.

View elmodos's full-sized avatar
🇺🇦

Modo Ltunzher elmodos

🇺🇦
View GitHub Profile
@elmodos
elmodos / revision.sh
Last active March 31, 2016 13:27
Add this script to Build Phases of your target in Xcode to automatically set build number with SVN/Git revision number
# set build number only for release (Product|Archive)
if [ "$CONFIGURATION" == "Release" ]; then
# get GIT revision number
buildNumber=`git rev-list --count HEAD`
# if not git, then get SVN revision number
if [[ -z "$buildNumber" ]]; then
buildNumber=`svn info | grep "Revision" | awk '{print $2}'`
fi
@elmodos
elmodos / espeak.sh
Created May 1, 2016 18:04
Linux, say current selection aloud, espeak
#!/bin/bash
# Get espeak PID if it is running
PID=`pgrep -x espeak`
echo Process ID: $PID
if [ -z $PID ];
then
# Not runnning
@elmodos
elmodos / .bashrc
Created October 21, 2016 14:29
256 color terminal for GUI terminal emulator
# paster this into the end of your ~/.bashrc file
# 256 color by default for X
if [ -n "$DISPLAY" -a "$TERM" == "xterm" ]; then
export TERM=xterm-256color
fi
@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=
@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 / dropbox.sh
Created November 24, 2016 20:01
Launch dropbox in xfce, tray icon fix
#!/bin/bash
dbus-launch dropbox start -i
#!/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"
;;
import UIKit
open class ZoomImageView: UIScrollView, UIScrollViewDelegate {
// MARK: Publics
public enum ZoomMode {
case fit
case fill
@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
@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