Skip to content

Instantly share code, notes, and snippets.

View aurels's full-sized avatar

Aurélien Malisart aurels

View GitHub Profile
@aurels
aurels / gist:1149400
Created August 16, 2011 15:50
Change hostname
sudo hostname mydomain.tld
@aurels
aurels / gist:1106934
Created July 26, 2011 14:52
Starting MongoDB after a crash on Ubuntu (+repair)
sudo rm /var/log/mongodb/mongod.lock
sudo -u mongodb mongod -f /etc/mongodb.conf --repair
sudo service mongodb start
@aurels
aurels / gist:1029263
Created June 16, 2011 13:51
FTP only user setup
sudo apt-get install pure-ftpd
sudo adduser blop
# add /bin/false to /etc/shells
# edit /etc/passwd to set /bin/false as shell
# edit /etc/pam.d/pure-ftpd to force the use of /etc/ftpallow
# add user blop to /etc/ftpallow
# Chroot everyone
@aurels
aurels / gist:843967
Created February 25, 2011 15:45
stream system command output to STDOUT (ruby)
IO.popen('ant run') do |io|
while (line = io.gets) do
puts line
end
end
@aurels
aurels / gist:822700
Created February 11, 2011 17:19
Recursive and readable disk usage for a directory
du -hx --max-depth 1 /var
@aurels
aurels / Sync NTP time
Created February 4, 2011 11:09
Set server date from an NTP server
sudo sh -c 'echo "ntpdate ntp.ubuntu.com" > /etc/cron.hourly/ntpsync'
sudo chmod 755 /etc/cron.hourly/ntpsync
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
NSLog(@"Deleting Task!");
Task *taskToRemove = [tasksArray objectAtIndex:indexPath.row];
//remove from taskArray
[tasksArray removeObjectAtIndex:indexPath.row];
//remove from core data and on server
[dm removeTask:taskToRemove];
//remove from UI
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.row == [tasksArray count])
return UITableViewCellEditingStyleInsert;
else
return UITableViewCellEditingStyleDelete;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return [tasksArray count]+1;
}
// Create a tabBarViewController
tabBarController = [[UITabBarController alloc] init];
// Create the view and the navigator controller for Contact
contactNavController = [[UINavigationController alloc] init];
ContactsViewController *contactsViewController = [[ContactsViewController alloc] initWithNibName:nil bundle:nil];
[contactsViewController initWithDataManager:dm];
[contactsViewController initWithStyle:UITableViewStylePlain];
contactsViewController.navigationItem.title = @"Contacts";
contactNavController.viewControllers = [NSArray arrayWithObjects:contactsViewController, nil];