Skip to content

Instantly share code, notes, and snippets.

View idiogo's full-sized avatar

Diogo Carneiro idiogo

View GitHub Profile
- (UIViewController*)topMostController
{
UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController;
while (topController.presentedViewController) {
topController = topController.presentedViewController;
}
return topController;
}
@idiogo
idiogo / gist:6409247
Last active December 22, 2015 03:18
Alerting on Mac the result of Google Converter (like "1 foot in meters"). I made this to search from Alfred App with Powerpack.
output=$(curl -sA Mozilla http://www.google.com/search?q=$(echo "1 foot in meters" | sed "s/ /+/g") | grep -E '[0-9]+(\.+[0-9]+)?\s[a-zA-z]+\s=\s[0-9]+(\.+[0-9]+)?\s[a-zA-z]+' -A 0 -B 0 -o) && echo -e "tell app \"System Events\" to display dialog \"$output\"" | osascript
@idiogo
idiogo / gist:6408163
Created September 2, 2013 00:10
Chrome Incognito from Mac OS X terminal
open /Applications/Google\ Chrome.app/ --args --incognito
@idiogo
idiogo / multiple parts zip compress
Created May 6, 2013 15:45
Compressing large files to multiple small files.
zip -r -s 100m archive.zip FolderName/
@idiogo
idiogo / UILabel+ColorInRanges.h
Created March 28, 2013 03:29
UILabel extension method that sets different color (attributed text) for string that matches given regex pattern. Dependencies: https://gist.github.com/idiogocarneiro/5260300
#import <UIKit/UIKit.h>
@interface UILabel (ColorInRanges)
- (void)changeTextColor:(UIColor *)color forStringsWithPattern:(NSString *)pattern;
@end
@idiogo
idiogo / NSString+RegularExpressionSearch.h
Last active December 15, 2015 12:29
Class and usage of the NSString extension method that returns the ranges of all strings found with given regex pattern
#import <Foundation/Foundation.h>
@interface NSString (RegularExpressionSearch)
- (NSArray *)stringRangesWithRegularExpressionPattern:(NSString *)patternString;
@end
@idiogo
idiogo / serial_write.php
Created March 28, 2013 03:02
Writing in serial port (USB) with PHP. Did this to control arduino via PHP server
<?php
exec("stty -f /dev/tty.usbmodemfa131 raw speed 9600");
exec("echo '".$_GET['status']."' > /dev/tty.usbmodemfa131");