This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(float)compareString:(NSString *)originalString withString:(NSString *)comparisonString | |
{ | |
// Normalize strings | |
[originalString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; | |
[comparisonString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; | |
originalString = [originalString lowercaseString]; | |
comparisonString = [comparisonString lowercaseString]; | |
// Step 1 (Steps follow description at http://www.merriampark.com/ld.htm) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Compiled source # | |
################### | |
*.com | |
*.class | |
*.dll | |
*.exe | |
*.o | |
*.so | |
# Packages # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Initialize the context. This is THE object you are going to use for all the data input and output. | |
// | |
NSManagedObjectContext* context=[[NSManagedObjectContext alloc] init]; | |
// | |
// Initialize the model file, some black magic and you don't need to specify the model file name. | |
// You can point to it manually but since they introduced "versioned" data model, it's hard to figure out what name or path you should use. | |
// | |
NSManagedObjectModel* model=[NSManagedObjectModel mergedModelFromBundles:nil]; | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#stop server | |
service mysqld stop | |
#start server without checking password | |
mysqld_safe --skip-grant-tables & | |
#log into server as root and specify "mysql" is the database going to be used | |
mysql --user=root mysql | |
#update the password | |
update user set Password=PASSWORD('new-password-here') WHERE User='root'; | |
#make the changes to take effect | |
flush privileges; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString* link=[NSString stringWithFormat:@"https://twitter.com/intent/tweet?url=http://google.com&text=",@"Some text that may have & damn you &&&"]; | |
link=[link stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; | |
link=[link stringByReplacingOccurrencesOfString:@"&" withString:@"%26" options:NSLiteralSearch range:NSMakeRange([link rangeOfString:@"&"].location+1, link.length-1)]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__block ASIHTTPRequest* req=[[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:url]]; | |
req.cachePolicy=ASIOnlyLoadIfNotCachedCachePolicy; | |
req.downloadCache=[ASIDownloadCache sharedCache]; | |
[req setCompletionBlock:^{ | |
UIImage* img=[UIImage imageWithData:[req responseData]]; | |
}]; | |
[req setFailedBlock:^{ | |
NSLog(@"Download Failed"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string getIPAddress(){ | |
string ipAddress="Unable to get IP Address"; | |
struct ifaddrs *interfaces = NULL; | |
struct ifaddrs *temp_addr = NULL; | |
int success = 0; | |
// retrieve the current interfaces - returns 0 on success | |
success = getifaddrs(&interfaces); | |
if (success == 0) { | |
// Loop through linked list of interfaces | |
temp_addr = interfaces; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL) validateEmail: (NSString *) candidate { | |
NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; | |
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex]; | |
return [emailTest evaluateWithObject:candidate]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This line is very important. It tells the server that this part is based on the name of the server, not IP address or anything else. | |
NameVirtualHost *:80 | |
# * means any ip address is fine. If you want to put, put your current server ip address. It's quite unlikely the server has multiple ip addresses. For normal people, * is good enough | |
<VirtualHost *:80> | |
#ServerName is used internally for Apache, so it does not matter what name you give it. As long as it does not conflict with other servers. | |
ServerName www.domain.tld | |
#This is the part specifies which domain it is serving. To be safe, always include the one without www and the one with www. | |
ServerAlias domain.tld www.domain.tld | |
#The files to be served for this domain. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openssl x509 -inform der -in cert.cer -out cert.pem | |
openssl pkcs12 -nocerts -in key.p12 -out key.pem | |
cat cert.pem key.pem > joined.pem |
OlderNewer