Skip to content

Instantly share code, notes, and snippets.

View nacho4d's full-sized avatar

Guillermo Ignacio Enriquez Gutierrez nacho4d

View GitHub Profile
@nacho4d
nacho4d / gitignore
Created June 13, 2012 17:43
My .gitignore for Xcode projects (Mac/iOS)
# Xcode
build/*
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcworkspace
xcuserdata
profile
@nacho4d
nacho4d / insertString.m
Created July 12, 2012 08:24
insert a string using UIKeyInput methods in UITextView in iOS5
- (void)insertString:(NSString *)inputKey
{
// Insert text (doing delegate calls appropiately)
NSRange changeRange = target.selectedRange;
if (!target.delegate || ([target.delegate respondsToSelector:@selector(textView:shouldChangeTextInRange:replacementText:)] &&
[target.delegate textView:target shouldChangeTextInRange:changeRange replacementText:inputKey])) {
// MarkedText could happen in multi-stage input languages
// In iOS5 several methods of UITextInput and UIKeyInput are badly implemented in UITextView
// setMarkedText:selectedRange: method seems to delete current markedText.
// Unmarking the text before inserting it is better than nothing.
@nacho4d
nacho4d / Shifted.m
Created August 7, 2012 18:27
Shift key is pressed ?
- (BOOL)_isShifted
{
BOOL res = NO;
Class uiKeyboardImpl = NSClassFromString(@"UIKeyboardImpl");
if ([uiKeyboardImpl respondsToSelector:@selector(activeInstance)]) {
id activeKeyboard = [uiKeyboardImpl performSelector:@selector(activeInstance)];
if ([activeKeyboard respondsToSelector:@selector(isShifted)]) {
res = ((BOOL)[activeKeyboard performSelector:@selector(isShifted)]);
}
}
@nacho4d
nacho4d / UIAutocorrectionInlinePrompt-Dismiss.m
Created October 8, 2012 07:11
Dismiss the UIAutocorrectionInlinePrompt manually - Private API
// Find and dismiss the UIAutocorrectionInlinePrompt view
// target is an instance of UITextView
NSArray *textviewSubviews = [target subviews];
NSInteger correctionViewIndex = [textviewSubviews indexOfObjectPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
if ([[[obj class] description] isEqualToString:@"UIAutocorrectInlinePrompt"]) {
*stop = YES;
return YES;
} else {
return NO;
}
@nacho4d
nacho4d / JSLint.sublime-build
Created October 15, 2012 15:54
JSLint sublime text build system file
{
"cmd": ["jsl", "-process", "$file", "-nologo", "-nocontext", "-nofilelisting"],
"file_regex": "^(.+\\.js)\\((\\d+)\\): (.+)$",
"selector": "source.js",
"osx": {
"path": "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
}
}
// Above settings are for output of the form:
@nacho4d
nacho4d / Typescript.sublime-build
Created October 19, 2012 08:59
Typescript sublime text build system file
{
"cmd": ["tsc","$file"],
"file_regex": "^(.+) \\((\\d+),(\\d+)\\): (.+)$",
"selector": "source.ts",
"osx": {
"path": "/usr/local/bin:/opt/local/bin"
}
}
@nacho4d
nacho4d / ShareFromSafari.scpt
Created November 16, 2012 11:08
Share from Safari
#!/usr/bin/osascript
-- Adaptation of @piyomaru 's
-- http://piyocast.com/as/archives/2142#comment-37021
-- socialItem: "Twitter", "Facebook", "Message"
on composePost(socialItem)
try
set postText to ""
@nacho4d
nacho4d / .bash_profile
Last active December 9, 2015 19:48
~/.bash_profile
export CLICOLOR=1
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
export LS_COLORS=$LSCOLORS
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
#PS1='\[\e[0;33m\][\h:\W \u]$\[\e[m\] '
PS1='\[\e[0;33m\][\w]$\[\e[m\] '
@nacho4d
nacho4d / checkXcodeSelect.sh
Last active December 13, 2015 22:19
Check xcode-select is installed and get Xcode path
# Check xcode-select to check Xcode + Developer tools are installed
command -v xcode-select >/dev/null 2>&1 || { echo >&2 "Make sure Xcode together with xcode-select command is installed. Aborting."; exit 1; }
XCODE_PATH=$(xcode-select --print-path 2>&1)
echo $XCODE_PATH
@nacho4d
nacho4d / installDocumentation.sh
Created February 19, 2013 08:11
Install *.docset files
#!/bin/sh
#
# Description:
# Installs the given *.docset so it is visible by Xcode, Dash, etc
#
# Usage:
# installDocumentation path/to/documentation.docset
#
# Check parameters