Skip to content

Instantly share code, notes, and snippets.

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

infolock infolock

👨‍👩‍👦‍👦
nqdq
View GitHub Profile
@infolock
infolock / .gitignore
Created October 3, 2016 14:15
Boilerplate Gitignore for macOS web (JS) development
bower_components/
node_modules/
tmp/
.AppleDouble
.LSOverride
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
@infolock
infolock / chmod_files_and_dirs.sh
Created October 10, 2013 23:46
*nix recursive find and change mod access for files and folders within a given path
# Recursively find all files in the current directory and change to access of 644
find ./ -type f -exec chmod 644 {} \;
# Recursively find all directories in the current directory and change to access of 755
find ./ -type d -exec chmod 755 {} \;
server {
listen 80;
server_name images.example.com;
access_log /var/sites/images.example.com/logs/access.log;
error_log /var/sites/images.example.com/logs/error.log;
root /var/sites/images.example.com/htdocs;
location / {
index index.php index.html index.htm;
}
location = /favicon.ico {
@infolock
infolock / .htaccess
Last active December 20, 2015 00:48
htaccess file containing Apache Mod Rewrite Rule(s) for doing a Subdomain Redirect (CloudFlare as the Nameserver, Godaddy As the host) The nginx conf file related to this htaccess file can be found here: https://gist.github.com/infolock/6044150 More information can be found in the full article: http://phpadvocate.com/blog/2013/07/apache-godaddy-…
# Author Jonathon Hibbard
##################### Godaddy Apache .htaccess for example.com #####################
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
##################### Try and prevent looping madness #####################
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
@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 {} \;
- (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);
@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.
*
//
// 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.
//
@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);
@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