I hereby claim:
- I am youssman on github.
- I am wassimboy (https://keybase.io/wassimboy) on keybase.
- I have a public key whose fingerprint is 137A D131 6310 FAAF 0E52 6293 F52D 1147 6974 5004
To claim this, I am signing this object:
<?php | |
// DISPLAYS COMMENT POST TIME AS "1 year, 1 week ago" or "5 minutes, 7 seconds ago", etc... | |
function time_ago($date,$granularity=2) { | |
$date = strtotime($date); | |
$difference = time() - $date; | |
$periods = array('decade' => 315360000, | |
'year' => 31536000, | |
'month' => 2628000, | |
'week' => 604800, | |
'day' => 86400, |
<?php | |
// 137 seconds => 2min 17s | |
protected function _timeConversion( $seconds ) { | |
$datetime = new DateTime('@' . $seconds, new DateTimeZone('UTC')); | |
$formatted = array( 'd' => $datetime->format('z'), | |
'h' => $datetime->format('G'), | |
'min' => $datetime->format('i'), | |
's' => $datetime->format('s') | |
); |
<?php | |
protected function compareFunction($a, $b){ | |
//any compare function (like strcmp, ...) or treatment we want | |
if ($a->objIntField == $b->objIntField) { | |
return 0; | |
} | |
return ( $a->objIntField > $b->objIntField ); | |
} | |
public function myAction(){ |
NSArray* split = [@"10/04/2011" componentsSeparatedByString: @"/"]; | |
NSString* mounth = [split objectAtIndex: 1]; |
<!-- ... --> | |
<!-- You have to use ${structure expresssion} syntax to escape HTML tags. | |
The use of "tal:define" (to handle the case when no string is defined in the array) is important | |
because we can't combine the two PHPTALES "structure" and "string" in the same expression. --> | |
<div tal:define="myVarWithTags string:a br tag<br/>for example"> | |
${structure myArray/ofString | myVarWithTags} | |
</div> | |
<!-- ... --> |
I hereby claim:
To claim this, I am signing this object:
NSArray *array1 = [NSArray arrayWithObjects:@"1", @"2", @"3", nil]; | |
NSString *joinedString = [array1 componentsJoinedByString:@","]; |
NSString *string = @" this text has spaces before and after "; | |
NSString *trimmedString = [string stringByTrimmingCharactersInSet: | |
[NSCharacterSet whitespaceCharacterSet]]; |
NSDictionary *underlineAttribute = @{NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle)}; | |
myLabel.attributedText = [[NSAttributedString alloc] initWithString:@"Underline UILabel text" attributes:underlineAttribute]; |
-(CGSize)frameForText:(NSString*)text sizeWithFont:(UIFont*)font constrainedToSize:(CGSize)size lineBreakMode:(NSLineBreakMode)lineBreakMode { | |
NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy]; | |
paragraphStyle.lineBreakMode = lineBreakMode; | |
NSDictionary * attributes = @{NSFontAttributeName:font, | |
NSParagraphStyleAttributeName:paragraphStyle | |
}; | |