PHP redirect
<?php header("Location: http://www.domain.com/index.php"); ?>
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
What next?
1. Bookmark us with del.icio.us or Digg Us!
2. Subscribe to this site's RSS feed
3. Browse the site.
4. Post your own code snippets to the site!
<?php header("Location: http://www.domain.com/index.php"); ?>
UIImage *buttonImageNormal = [UIImage imageNamed:@"whiteButton.png"]; UIImage *stretchableButtonImageNormal = [buttonImageNormal stretchableImageWithLeftCapWidth:12 topCapHeight:0]; [doSomethingButton setBackgroundImage:stretchableButtonImageNormal forState:UIControlStateNormal]; UIImage *buttonImagePressed = [UIImage imageNamed:@"blueButton.png"]; UIImage *stretchableButtonImagePressed = [buttonImagePressed stretchableImageWithLeftCapWidth:12 topCapHeight:0]; [doSomethingButton setBackgroundImage:stretchableButtonImagePressed forState:UIControlStateHighlighted];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(issue_id == %i)", 2]; NSArray *newArray = [youDictionaryArray filteredArrayUsingPredicate:predicate];
- (NSString *) MD5{ const char* string = [self UTF8String]; unsigned char result[16]; CC_MD5(string, strlen(string), result); NSString* hash = [NSString stringWithFormat:@"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7], result[8], result[9], result[10], result[11], result[12], result[13], result[14], result[15]]; return [hash lowercaseString]; }
-(void) ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event { BOOL moveX, moveY = NO; CGPoint touchLocation = [touch locationInView: [touch view]]; touchLocation = [[CCDirector sharedDirector] convertToGL: touchLocation]; touchLocation = [self convertToNodeSpace:touchLocation]; CGPoint playerPos = _player.position; CGPoint diff = ccpSub(touchLocation, playerPos); CGSize winSize = [[CCDirector sharedDirector] winSize]; // Define areas on the screen to control player differently // Centralised cross that will move directly up, down, left or right (winsize.width/3, winsize.height/3) // Remaining areas will move diagonally // If central crossover area is pressed, player will not move. // Left/right press if (touchLocation.x < winSize.width/3) { moveX = YES; } else if (touchLocation.x > ((winSize.width/3)*2)) { moveX = YES; } else { moveX = NO; } // Up/down press if (touchLocation.y < winSize.height/3) { moveY = YES; } else if (touchLocation.y > ((winSize.height/3)*2)) { moveY = YES; } else { moveY = NO; } if (moveX) { if (diff.x >= _tileMap.tileSize.width) { playerPos.x += _tileMap.tileSize.width; } else if (diff.x <= (_tileMap.tileSize.width * -1)) { playerPos.x -= _tileMap.tileSize.width; } } if (moveY) { if (diff.y >= _tileMap.tileSize.height) { playerPos.y += _tileMap.tileSize.height; } else if (diff.y <= (_tileMap.tileSize.height * -1)) { playerPos.y -= _tileMap.tileSize.height; } } if (moveX || moveY) { if (playerPos.x <= (_tileMap.mapSize.width * _tileMap.tileSize.width) && playerPos.y <= (_tileMap.mapSize.height * _tileMap.tileSize.height) && playerPos.y >= 0 && playerPos.x >= 0 ) { [self setPlayerPosition:playerPos]; } } }
/* remove all margins and padding */ * { margin: 0px; padding: 0px; } /* remove borders from any images that have links around them */ img { border:none; } /* remove default cellspacing and cellpadding, and set a width */ table { border-collapse: collapse; width:100%; } /* all table cells align to top (not middle) and header cells to left */ td, th { vertical-align:top; text-align:left; }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="imagetoolbar" content="no" /><!-- kills IE's img toolbar --> <meta name="MSSmartTagsPreventParsing" content="true" /><!-- kills related links in XP --> <link rel="stylesheet" type="text/css" href="/styles/main.css" /> </head><body><div id="page"> <div id="header"> <h1>Header</h1> </div><!--END #header--> <div id="content"> </div><!--END #content --> <div id="footer"> <h1>Footer</h1> </div><!--END #footer --> </div><!--END #page --></body></html>
<xsl:template match="//question"> <question> <xsl:copy-of select="*"/> <xsl:apply-templates select="//answer[question_id = current()/id]"/> </question> </xsl:template> <xsl:template match="//answer"> <answer> <xsl:copy-of select="*"/> </answer> </xsl:template>
/* group by */ SELECT department, SUM(sales) AS total_sales FROM order_details GROUP BY department; /* group_concat */ SELECT GROUP_CONCAT(popname ORDER BY popname ASC SEPARATOR ', ') FROM populations; /* group_concat as aggregate function with group by: SELECT state, GROUP_CONCAT(city) AS cities FROM bigcities GROUP BY state;
/* this duplicates the table and all data in it */ CREATE TABLE new_table SELECT * FROM old_table; /* this duplicates only a portion of the data, for testing */ CREATE TABLE new_table SELECT * FROM old_table WHERE field1='value' LIMIT 0, 10000;