Skip to content

Instantly share code, notes, and snippets.

@stuwilli
stuwilli / gist:3395000
Created August 19, 2012 13:58 — forked from happy-coding/gist:3363334
Core Data AppDelegate Code
#pragma mark - Core Data stack
- (NSManagedObjectContext *)managedObjectContext
{
if (_managedObjectContext != nil) {
return _managedObjectContext;
}
NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
if (coordinator != nil) {
@stuwilli
stuwilli / AppDelegate.m
Created August 19, 2012 20:45
Core Data App Delegate sample config
@implementation WSAppDelegate
@synthesize persistentStoreCoordinator = _persistentStoreCoordinator;
@synthesize managedObjectModel = _managedObjectModel;
@synthesize managedObjectContext = _managedObjectContext;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSManagedObjectContext *context = [self managedObjectContext];
Names *name = [NSEntityDescription insertNewObjectForEntityForName:@"Names" inManagedObjectContext:context];
@stuwilli
stuwilli / NSLogCheatSheet.m
Created August 21, 2012 19:24
NSLog Cheat Sheet
NSLog(@"%@", songTitle);
NSLog(@"%@", songDuration);
NSLog(@"%f", [songDuration floatValue]);
NSLog(@"%d", [songDuration integerValue]);
# This file is sourced by /etc/init.d/sabnzbdplus
#
# When SABnzbd+ is started using the init script, the
# --daemon option is always used, and the program is
# started under the account of $USER, as set below.
#
# Each setting is marked either "required" or "optional";
# leaving any required setting unconfigured will cause
# the service to not start.
@stuwilli
stuwilli / standalone.xml
Created February 1, 2014 22:11
Jboss AS7 standalone config HS2 DB and JMS
<?xml version='1.0' encoding='UTF-8'?>
<server xmlns="urn:jboss:domain:1.2">
<extensions>
<extension module="org.jboss.as.clustering.infinispan"/>
<extension module="org.jboss.as.clustering.jgroups"/>
<extension module="org.jboss.as.cmp"/>
<extension module="org.jboss.as.configadmin"/>
<extension module="org.jboss.as.connector"/>
# First add a rule for all local traffic to port 80 to go into pipe 1
# 100 is the rule number which will be used for referencing the rule later
sudo ipfw add 100 pipe 1 ip from 127.0.0.1 to 127.0.0.1 dst-port http
# To display the rule use
# sudo ipfw show 100
# configure the settings of the pipe as you please
# 50kbit/s bandwidth
sudo ipfw pipe 1 config bw 50Kbit
# 200ms lag
@stuwilli
stuwilli / gist:9580481
Created March 16, 2014 09:10
How to Floor, Round, Ceiling in JSTL/EL
Floor(N) -> ${N-(N%1)}
Ceiling(N) -> ${N+(1-(N%1))%1}
Round(N) -> ${N+((N%1>0.5)?(1-(N%1))%1:-(N%1))}
@stuwilli
stuwilli / pagination.tag
Last active August 29, 2015 13:57
Spring Data Pagination Taglib
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ attribute name="pg" type="org.springframework.data.domain.Page" required="true" rtexprvalue="true" description="The current Page" %>
<c:set var="showPages" value="10" />
<%-- No User Settings Below Here --%>
@stuwilli
stuwilli / 0_reuse_code.js
Created March 16, 2014 15:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@stuwilli
stuwilli / gist:04c0f3f35925e35bbf49
Last active August 29, 2015 14:10
Jenkins Post Build Script - Package
#!/bin/bash
WWW_PATH=/srv/www/public
DIST_DIR=./dist
RELEASE_DIR=$WWW_PATH/$JOB_NAME
RELEASE_NAME=$(echo $JOB_NAME | awk '{print tolower($0)}')
if [ ! -d "$RELEASE_DIR" ]; then
mkdir -p $RELEASE_DIR/testing