Skip to content

Instantly share code, notes, and snippets.

View priore's full-sized avatar

Priore priore

View GitHub Profile
@priore
priore / gist:7163659
Created October 25, 2013 23:58
Copy files with SQL
--
-- Created by Danilo Priore.
-- Copyright (c) 2012 Prioregroup.com. All rights reserved.
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
@priore
priore / gist:7163664
Created October 25, 2013 23:59
Execute a DTS from SQL
--
-- Created by Danilo Priore.
-- Copyright (c) 2012 Prioregroup.com. All rights reserved.
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
@priore
priore / gist:7163673
Created October 25, 2013 23:59
Send an email with GMail account and CDO Components
'
' Created by Danilo Priore.
' Copyright (c) 2012 Prioregroup.com. All rights reserved.
'
'
' Permission is hereby granted, free of charge, to any person obtaining a copy
' of this software and associated documentation files (the "Software"), to deal
' in the Software without restriction, including without limitation the rights
' to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
' copies of the Software, and to permit persons to whom the Software is
@priore
priore / gist:7163691
Last active December 26, 2015 14:09
ReviewEngine simplifies the calling to app internet page for requesting a user review of the app on the app store. To use it simply drop the two files into your code and then add one method call to get it working.
//
// ReviewEngine.h
//
// Created by Danilo Priore on 23/11/11.
// Copyright (c) 2011 Prioregroup.com. All rights reserved.
//
// ReviewEngine simplifies the calling to app internet page for requesting a
// user review of the app on the app store. To use it simply drop the two
// files into your code and then add one method call to get it working.
@priore
priore / gist:8134505
Created December 26, 2013 14:35
Convert Unicode string into readable string
NSString *input = @"\\u5404\\u500b\\u90fd";
CFStringTransform((__bridge CFMutableStringRef)input, NULL, CFSTR("Any-Hex/Java"), YES);
NSLog(@"Readable string: %@", input);
@priore
priore / gist:8496194
Created January 18, 2014 20:48
UILabel text size fit macro
// UILabel text size fit macro
//
// use :
//
// UILabel *label = ....
// TEXT_FIT(label, @"your text here");
//
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define TEXT_FIT_IOS6(t,txt) (CGRect){t.frame.origin, t.frame.size.width, [txt sizeWithFont:t.font constrainedToSize:t.frame.size lineBreakMode:t.lineBreakMode].height}
#define TEXT_FIT_IOS7(t,txt) (CGRect){t.frame.origin, t.frame.size.width, [txt boundingRectWithSize:t.frame.size options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:t.font} context:nil].size.height}
@priore
priore / gist:8496203
Created January 18, 2014 20:49
XML formatter for TextWrangler
# put script in ~/Library/Application Support/TextWrangler/Text Filters/Tidy XML.py
#!/bin/sh
XMLLINT_INDENT=$'\t' xmllint --format --encode utf-8 -
@priore
priore / gist:8496208
Created January 18, 2014 20:49
JSON formatter for TextWrangler
# put script in ~/Library/Application Support/TextWrangler/Text Filters/Format JSON.py
#!/usr/bin/python
import fileinput
import json
if __name__ == "__main__":
text = ''
for line in fileinput.input():
text = text + ' ' + line.strip()
jsonObj = json.loads(text)
print json.dumps(jsonObj, sort_keys=True, indent=2)
@priore
priore / gist:8496221
Last active January 3, 2016 17:29
Convert Unicode string into readable string
NSString *input = @"\\u5404\\u500b\\u90fd";
CFStringTransform((__bridge CFMutableStringRef)input, NULL, CFSTR("Any-Hex/Java"), YES);
NSLog(@"Readable string: %@", input);
@priore
priore / NSDictionary+Values.m
Last active August 29, 2015 14:01
Fixes crash in case of missing of the partial KeyPath in NSDictionary
@implementation NSDictionary (Values)
- (id)valueForKeyPath:(NSString *)keyPath
{
__block id value = nil;
if (keyPath != nil) {
NSArray *keys = [keyPath componentsSeparatedByString:@"."];
if (keys && [keys count] > 0) {
[keys enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {