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
void FindPrimeNumber(int size, int results[]) { | |
// create elements array | |
int *elements; | |
elements = (int *)malloc(size * sizeof(int)); | |
for (int i = 0; i < size ; i++) { | |
elements[i] = 1 ; | |
} | |
//start to cross out. Beginning from i = 2 |
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
/** | |
Inspect input number to see if there is nil input or null object input | |
@param aNumber an input number | |
@return If nil input or null object input found, a NSNumber object with zero value will return. | |
If the input is a NSStirng object, a NSNumber object contianing dobleValue of the string will return. | |
@warning If input number is not a NSNumber or NSString, a NSNumber object containing zero will return. | |
*/ |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <String.h> | |
/* | |
* === FUNCTION ====================================================================== | |
* Name: del_str | |
* Description: Delete substring in the source string | |
* ===================================================================================== | |
*/ |
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
char *rewind_string(char *last_char) { | |
// Prevent NUL byte. | |
if (*last_char == '\0' || last_char == NULL) { | |
return NULL; | |
} | |
char *first_char; | |
// Rewind to the pointer pointing to first character. | |
for (first_char = last_char; *first_char != '\0'; first_char--); |
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
size_t strlength(char const *string) { | |
int length = 0; | |
while (*string++ != '\0') { | |
length += 1; | |
} | |
return length; | |
} | |
char *find_char(char const *source, char const *chars) { |
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
// 1. Before using following code snippet, make sure to add textfields on a UIScrollView | |
// 2. The following code snippet will lead the first responder textfield just top of showing keyboard. | |
// 3. The trick is to set enough scrolling space for scroll view to raise all textfields up. | |
// When target textfield is touched, the scroll view will do the animation automatically and raise textfields up. | |
// 4. Do not combine other technique to raise up textfields over keyboard. | |
- (instancetype)init | |
{ | |
self = [super init]; | |
if (self) { |
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
char *stradd(const char *a, const char *b){ | |
size_t len = strlen(a) + strlen(b); | |
char *ret = (char *)malloc(len * sizeof(char) + 1); | |
return strcat(strcat(ret, a), b); | |
} | |
char *binaryConverter(int input_number) { | |
int number = input_number; | |
char *binaryString = (char *)malloc(sizeof(char)); | |
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
When pod install or pod update gets hanged at "Analyzing dependencies", please consider to reinstall cocoapods. | |
#Uninstallation. Reference: http://superuser.com/questions/686317/how-to-fully-uninstall-the-cocoapods-from-the-mac-machine | |
$gem list --local | grep cocoapods | |
#The list will show like this | |
cocoapods (0.27.1, 0.20.2) | |
cocoapods-core (0.27.1, 0.20.2) | |
cocoapods-downloader (0.2.0, 0.1.2) |
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
// Inspired by Blended Cocoa | |
// Reference: http://www.blendedcocoa.com/blog/2012/10/25/objective-c-literals-negative-array-subscripts/ | |
#import <objc/runtime.h> | |
@implementation NSArray (CatchIndexOutOfRange) | |
+ (void)load | |
{ | |
static dispatch_once_t onceToken; |
NewerOlder