Skip to content

Instantly share code, notes, and snippets.

View kwylez's full-sized avatar

Cory D. Wiles kwylez

View GitHub Profile
<?php
foreach (new DirectoryIterator('./') as $fileInfo) {
if($fileInfo->isDot()) continue;
echo $fileInfo->getFilename() . "<br>\n";
}
?>
<?php
// PHP version < 5.3
function compareFileName($a, $b, $keyToSortBy) {
return strnatcmp($a[$keyToSortBy], $b[$keyToSortBy]);
}
usort($arrayThatIsPopulated, 'compareFileName');
// PHP version >= 5.3
usort($arrayThatIsPopulated, function($a, $b, $keyToSortBy) {
<?php
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
$response = array();
$jsonResponse = '';
$gallery = '';
$galleryImages = array();
$galleryDirectories = array();
/**
* origFrame and origCenter are properties
*/
origFrame = self.customView.frame;
origCenter = self.customView.center;
[UIView animateWithDuration:2.0
animations:^ {
CGFloat tabMiddle = CGRectGetMidX([[[[[self tabBarController] tabBar] subviews] objectAtIndex:tabIndex] frame]);
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {
[self.delegate tabBarController:self didSelectViewController:self.selectedViewController];
}
#!/usr/local/zend/bin/php
<?php
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
try {
$db = Zend_Db::factory('Pdo_Mssql', array(
CGPoint roundedCenterPoint(CGPoint pt) {
return CGPointMake(round(pt.x), round(pt.y));
}
leftLabel.frame = CGRectIntegral(leftLabelFrame);
leftLabel.center = roundedCenterPoint(leftLabel.center);
@kwylez
kwylez / gist:1267291
Created October 6, 2011 12:30
Steve Jobs
SteveJobs *spj = [[SteveJobs alloc] initWithExtraordinary:genius withWorldChanging:vision];
[spj execute];
NSDateComponents *components = [[NSDateComponents alloc]init];
[components setDay:5];
[components setMonth:10];
@kwylez
kwylez / gist:1339398
Created November 4, 2011 14:09
Convert Python Class Instance to JSON
# http://stackoverflow.com/questions/1531501/json-serialization-of-google-app-engine-models
class jsonEncoder(simplejson.JSONEncoder):
def default(self, obj):
isa = lambda x: isinstance(obj, x) # isa(<type>)==True if obj is of type <type>
return obj.isoformat() if isa(datetime.datetime) else \
db.to_dict(obj) if isa(db.Model) else \
obj.email() if isa(users.User) else \
simplejson.JSONEncoder.default(self, obj)