Skip to content

Instantly share code, notes, and snippets.

if (parameters) {
if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) {
NSString *charset = (__bridge NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding));
[mutableRequest setValue:[NSString stringWithFormat:@"application/json; charset=%@", charset] forHTTPHeaderField:@"Content-Type"];
}
[mutableRequest setHTTPBody:[NSJSONSerialization dataWithJSONObject:parameters options:self.writingOptions error:error]];
}
@rad3ks
rad3ks / Purger
Created December 19, 2012 22:38
Simple script for Mac users who feel lack of free memory. Script automatically purges memory every 10 minutes, if there is less than 20 MB free.
#! /bin/sh
# Purging memory if there is less than 20 MB free.
# Author: Radosław Szeja
# Date: 9.12.2012
while true; do
fm=`top -l 1 | awk '/PhysMem/ {print $10}' | sed -e 's/\([0-9]*\)\(M\)/\1/g'`;