Skip to content

Instantly share code, notes, and snippets.

@rais38
rais38 / gist:5766980
Created June 12, 2013 16:35
Create patch from stash
git stash show -p stash@{0} > Stash0.patch
@rais38
rais38 / gist:5661946
Last active January 5, 2021 16:30
On Mac OS X (LaunchServices and UTIs) to convert a file path to the file's MIME type using.
+ (NSString *)MIMETypeForFileAtPath:(NSString *)path defaultMIMEType:(NSString *)defaultType
{
NSString *result = defaultType;
NSString *extension = [path pathExtension];
CFStringRef uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension,
(CFStringRef)extension,
NULL);
if (uti) {
CFStringRef cfMIMEType = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType);
if (cfMIMEType) {
@rais38
rais38 / gist:4683817
Last active October 13, 2020 17:36
Embed YouTube videos with UIWebView
#pragma mark - Embed Video
- (UIWebView *)embedVideoYoutubeWithURL:(NSString *)urlString andFrame:(CGRect)frame {
NSString *videoID = [self extractYoutubeVideoID:urlString];
NSString *embedHTML = @"\
<html><head>\
<style type=\"text/css\">\
body {\
background-color: transparent;\
@rais38
rais38 / gist:6ecead686af9291da542
Created July 9, 2014 09:53
Watchpoint in LLDB
Set a watchpoint on a variable when it is written to.
(lldb) watchpoint set variable -w write global_var
(lldb) watch set var -w write global_var
(gdb) watch global_var
Set a watchpoint on a memory location when it is written into. The size of the region to watch for defaults to the pointer size if no '-x byte_size' is specified. This command takes raw input, evaluated as an expression returning an unsigned integer pointing to the start of the region, after the '--' option terminator.
(lldb) watchpoint set expression -w write -- my_ptr
(lldb) watch set exp -w write -- my_ptr
(gdb) watch -location g_char_ptr
Set a condition on a watchpoint.
(lldb) watch set var -w write global
@rais38
rais38 / gist:11272383
Created April 24, 2014 22:59
Retrieve current branch OSX
- (NSString *)projectDirectoryPath
{
NSWindowController *currentWindowController = [[NSApp mainWindow] windowController];
id document = [currentWindowController document];
if (currentWindowController && [document isKindOfClass:NSClassFromString(@"IDEWorkspaceDocument")]) {
NSURL *workspaceDirectoryURL = [[[document valueForKeyPath:@"_workspace.representingFilePath.fileURL"] URLByDeletingLastPathComponent] filePathURL];
if(workspaceDirectoryURL) {
return [workspaceDirectoryURL path];
}
}
@rais38
rais38 / gist:8664759
Created January 28, 2014 09:42
Perfect for debugging animations
p [(CALayer *)[[[[UIApplication sharedApplication] windows] objectAtIndex:0] layer] setSpeed:.1f]
@rais38
rais38 / Appirater.md
Last active December 30, 2015 05:59
Pequeño documento donde explico los parámetros más interesantes de Appirater

##Appirater

Appirater creo que es la librería open source más utilizada en Objective-C para recordar al usuario que si le gusta nuestra app que la vote.

###Configuración

daysUntilPrompt

Los usuarios tendrán que tener la misma versión para que surta efecto. Se puede configurar el número de días que han pasado de la última vez que se mostró el aviso.

usesUntilPrompt

@rais38
rais38 / gist:7589410
Last active December 29, 2015 00:59
How to Create an OS X Mavericks USB Installation Drive.

@see http://lifehacker.com/how-to-create-an-os-x-mavericks-usb-installation-drive-1450280026

  • Download OS X Mavericks from the Mac App Store, if you haven't already. If it tries to start the installation, just close it.
  • Insert your USB drive (you'll need one that's 8GB or larger) and open Disk Utility.
  • Select your drive in the sidebar and go to the Erase tab. Format the drive as "Mac OS Extended (Journaled)" and name the drive "Untitled." (Note: if you already have a drive or partition named "Untitled" connected to your computer, name it something else and change the corresponding variable in step 5's terminal command, or you might experience data loss!).
  • Click the Erase button and wait for Disk Utility to finish.
  • Close Disk Utility and open up a Terminal window. Copy and paste the command into the Terminal.
sudo /Applications/Install\ OS\ X\ Mavericks.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath /Applications/Install\ OS\ X\ Mavericks.app --nointe
@rais38
rais38 / gist:7352813
Created November 7, 2013 10:57
Show/Hidden all files in OSX
$ defaults write com.apple.finder AppleShowAllFiles -boolean true;
$ killall Finder
@rais38
rais38 / gist:7333977
Last active December 27, 2015 13:29
By default, Quick Look does not allow copy/paste when previewing a document. Here’s a quick fix. From a terminal enter the following:
$ defaults write com.apple.finder QLEnableTextSelection -boolean true;
$ killall Finder