Skip to content

Instantly share code, notes, and snippets.

View maxkramer's full-sized avatar

Max Kramer maxkramer

View GitHub Profile
#!/bin/sh
cd /Volumes/Cerberus;
now = $(date +"%m_%d_%Y");
mkdir "Backup_$now";
cd "Backup_$now";
cp ~/ ./;
@maxkramer
maxkramer / gist:5561443
Created May 11, 2013 21:12
Perform block on main thread
static void performOnUIThread(void (^Block)()) {
dispatch_async(dispatch_get_main_queue(), Block);
}
@maxkramer
maxkramer / Daily Server Reporting
Last active December 16, 2015 00:49
Daily server reporting via email. Make sure you add a cron job to run it, and edit all of the email addresses! e.g. 59 23 * * * /home/max/dailyreport.sh > /dev/null 2>&1
#!/bin/bash
apt-get update
(
echo To: [email protected]
echo From: reporting@`hostname`
if [ "$( df -h | grep hda1 | cut -c40-42)" -ge "80" ]; then echo Subject: Production Server : Low Disk Space : Daily reporting for `date +%e\ %B\ %Y`
else echo Subject: Production Server: Daily reporting for `date +%e\ %B\ %Y`
fi
echo Reporting of Production Server: `hostname`
echo
@maxkramer
maxkramer / gist:5156924
Created March 13, 2013 22:19
CSS Forced Anti-Aliasing
html {
-webkit-font-smoothing: antialiased;
-moz-font-smoothing: antialiased;
font-smoothing: antialiased;
}
@maxkramer
maxkramer / gist:4734734
Created February 7, 2013 22:15
/etc/dovecot/dovecot.conf
# Dovecot configuration file
# If you're in a hurry, see http://wiki.dovecot.org/QuickConfiguration
# "doveconf -n" command gives a clean output of the changed settings. Use it
# instead of copy&pasting files when posting to the Dovecot mailing list.
# '#' character and everything after it is treated as comments. Extra spaces
# and tabs are ignored. If you want to use either of these explicitly, put the
# value inside quotes, eg.: key = "# char and trailing whitespace "
@maxkramer
maxkramer / Codeigniter Bash Create
Created September 26, 2012 22:46
Create new Codeigniter Project
function codeigniter() {
git clone https://github.com/EllisLab/CodeIgniter.git "$@" ;
}
@maxkramer
maxkramer / NSArray - arrayCreate()
Created August 8, 2012 16:47
Quick NSArray creation objective-c
NSArray *arrayCreate(id firstObject, ...) {
NSMutableArray *objects = [NSMutableArray array];
[objects addObject:firstObject];
va_list args;
va_start(args, firstObject);
id arg;
while ((arg = va_arg(args, id))) {
if (arg == nil)
break;
[objects addObject:arg];
@maxkramer
maxkramer / UIImagePicker Image Orientation Normalizer
Created June 30, 2012 15:13
UIImagePicker Image Orientation Normalizer
- (UIImage *)normalizedImage {
if (self.imageOrientation == UIImageOrientationUp) return self;
UIGraphicsBeginImageContextWithOptions(self.size, NO, self.scale);
[self drawInRect:(CGRect){0, 0, self.size}];
UIImage *normalizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return normalizedImage;
}
@maxkramer
maxkramer / transparentModalViewController.m
Created May 23, 2012 06:58 — forked from frr149/transparentModalViewController.m
How to create a transparent modal View Controller
#pragma mark - Transparent Modal View
-(void) presentTransparentModalViewController: (UIViewController *) aViewController
animated: (BOOL) isAnimated
withAlpha: (CGFloat) anAlpha{
self.transparentModalViewController = aViewController;
UIView *view = aViewController.view;
view.opaque = NO;
view.alpha = anAlpha;
- (void) handlePan:(UIPanGestureRecognizer *) gesture {
if ((gesture.state == UIGestureRecognizerStateChanged) ||
(gesture.state == UIGestureRecognizerStateEnded)) {
CGPoint location = [gesture locationInView:[self.tableView superview]];
if (location.x <= (_tableView.frame.size.width / 2) + 40) {
if (location.x < _tableView.frame.size.width / 2-70 && isFilterViewShowing)
[self.tableView setFrame:CGRectMake(location.x, 0, _tableView.frame.size.width, _tableView.frame.size.height)];
else if (location.x < _tableView.frame.size.width / 2 + 40)