Skip to content

Instantly share code, notes, and snippets.

View infolock's full-sized avatar
👨‍👩‍👦‍👦
nqdq

infolock infolock

👨‍👩‍👦‍👦
nqdq
View GitHub Profile
@infolock
infolock / .bashrc
Last active August 29, 2015 13:58
bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Path to where the scripts being included below live. Update this to reflect your own paths..
# In this example, we will assume there is a tools folder in your $HOME folder...
TOOLS_PATH=$HOME/tools
# Force vi to be vim
// Creating method from code found here: https://gist.github.com/bennadel/9751583#file-code-4-js
// Used with jsperf
var _charArr = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "{", "}", "|", ":", "\"", "<", ">", "?", "~", "!", "@", "#", "$", "%", "&", "^", "&", "*", "(", ")", "_", "+", " ", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "[", "]", "\\", ";", "'", ",", ".", "/"];
var randomStr( maxLen ) {
var rndKey = 0;
var str = "";
var i;
##
# Below are the steps taken to install the GuestAdditions on a VirtualBox Centos 6.5 Instance. This was done to setup sharing between Mac OSX and CentOS 6.5.
#
# Login to the GUEST ( your actual VirtualBox CentOS Instance ), update `yum` and install the necessary packages
#
##
yum update
yum --enablerepo rpmforge install dkms
yum --enablerepo rpmforge install dkms
@infolock
infolock / swift-json-parse.swift
Last active August 29, 2015 14:06
Swift JSON Parse
import Foundation
// This can go in its own separate swift file - just keeping it here for reference..
struct MyModel {
let name: String
let email: String
static func create( name: String, email: String ) -> MyModel {
return MyModel( name: name, email: email )
}
@infolock
infolock / dismissKeyboard.h
Last active December 17, 2015 05:09
Different ways one can dismiss a keyboard by tapping the background
@interface someController : UIViewController
@property (nonatomic, weak) UITextField *someTextField;
-(void)dismissKeyboard;
@end
@infolock
infolock / CurrencyExample.mm
Last active December 17, 2015 23:58
UITextField delegate method shouldChangeCharactersInRange for allowing a valid currency value with the format of $x.xx. The following rules are enforced: 1) The value within the textField begins with a $ 2) Allows a decimal to be inserted only when there is 1 or more integers already in the field 3) Prevents more than 1 decimal to be inserted 4)…
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
NSString *textValue = textField.text;
if(textValue.length > 0 && string.length > 0) {
NSRange dotRange = [textValue rangeOfString:@"."];
BOOL isDot = [string isEqualToString:@"."];
if(isDot) {
return (dotRange.length == 0);
//
// ARSearchBar.h
// Artsy Folio
//
// Created by orta therox on 18/04/2012.
// Released under The MIT License
// http://www.opensource.org/licenses/mit-license.php
//
// Copyright (c) 2012 http://art.sy. All rights reserved.
//
@interface NSObject (MHOverride)
/*
* Dynamically overrides the specified method on this particular instance.
*
* The block's parameters and return type must match those of the method you
* are overriding. However, the first parameter is always "id _self", which
* points to the object itself.
*
- (CGImageRef)createMaskFromAlphaChannel:(UIImage *)image
{
size_t width = image.size.width;
size_t height = image.size.height;
NSMutableData *data = [NSMutableData dataWithLength:width*height];
CGContextRef context = CGBitmapContextCreate(
[data mutableBytes], width, height, 8, width, NULL, kCGImageAlphaOnly);
@infolock
infolock / gist:6024993
Created July 17, 2013 22:09
Shell command to quickly copy a LICENSE (ie: /documents/LICENSE) file into a all subdirectories where all of my github projects are located : (ie: /sources/github/ contains jsToolkit, PHPToolset, etc.). This maxdepth option keeps it isolated to just the root of the subdirectories. removing it will traverse the entire directory tree and copy all …
find /sources/github -type d -maxdepth 1 -exec cp -i /documents/LICENSE {} \;