Skip to content

Instantly share code, notes, and snippets.

View jsumners's full-sized avatar

James Sumners jsumners

View GitHub Profile
@jsumners
jsumners / write_png_from_clipboard.as
Created April 4, 2012 19:11
Do you have a screenshot in your OS X clipboard? Write it to a PNG!
set d to the clipboard as «class PNGf»
set fid to open for access "/tmp/screenshot.png" with write permission
write d to fid
close access fid
-- http://www.michael-hogg.co.uk/applescript.php
-- helped me figure this one out
@jsumners
jsumners / NSData+Base64.h
Created September 10, 2012 18:52 — forked from Abizern/NSData+Base64.h
A category on NSData for coding and encoding Base64
//
// NSData+Base64.h
// base64
//
// Created by Matt Gallagher on 2009/06/03.
// Copyright 2009 Matt Gallagher. All rights reserved.
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software. Permission is granted to anyone to
@jsumners
jsumners / NSDictionary+JBSObjectForPath.h
Created October 9, 2012 17:38
A category for retrieving objects from nested NSDictionaries
#import <Foundation/Foundation.h>
@interface NSDictionary (JBSObjectForPath)
/**
Returns the object from a nested `NSDictionary` at the given path, with path
components separated by a "/". For example, if you have the following
dictionary:
~~~~
{"foo":{"bar":"foobar"}}
@jsumners
jsumners / UIColor+JBSUtilities.m
Created October 9, 2012 20:47
Screw all of the bullshit llvm warnings in UIColor-Utilities
#import <UIKit/UIKit.h>
@interface UIColor (JBSUtilities)
/**
Give it a hex string, e.g. "#FFEEDD" or "FFEEDD", get back the UIColor
representation.
@param stringToConvert A NSASCIIStringEncoding hex string.
@return The UIColor represented by the hex string.
@jsumners
jsumners / UIApplication+iPhoneVersion.h
Created November 2, 2012 18:38
A category on UIApplication for determining the iPhone device
#import <UIKit/UIKit.h>
#define IS_IPHONE (!IS_IPAD)
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPhone)
/**
Provides a few methods to determine what sort of device the application is
running on. Specifically, the methods make it easy to determine what sort of
iPhone resolution is available: `[[UIApplication sharedApplication] isIphone3]`
*/
@jsumners
jsumners / pom.xml
Last active December 19, 2015 02:58
A base pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jrfom</groupId>
<artifactId>CHANGE-ME</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
@jsumners
jsumners / logback.xml
Last active March 19, 2018 18:32
A basic Logback configuration template for use in an IntelliJ IDEA file template. Very easily used as a generic template as well.
<configuration scan="true" scanPeriod="1 minute">
<variable
name="logPattern"
value="%-30(%d{MMM dd YYYY HH:mm:ss.SSS} [%thread]) %-5level %logger{5} [%file:%line] - %msg%n" />
<!--
The base name of the log file. For "example.log" this would
simply be "example". Or if it were "logs/example.log" then
"logs/example".
@jsumners
jsumners / fw.sh
Created October 7, 2013 20:18
A simple iptables script usable on any new server. Build from it.
#!/bin/bash
## Initial firewall building script.
## Should be run as root.
it=$(which iptables)
################################################################################
## Use this section to establish prerouted port redirects.
## For example, redirect port "80" to port "8080".
@jsumners
jsumners / OjdbcDriverListener.java
Last active December 31, 2015 21:29
POS Oracle drivers refusing to unload, causing memory leaks, and killing the god damn PermGen space.
package com.jrfom.fuck.oracle;
import java.lang.management.ManagementFactory;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Enumeration;
import java.util.Hashtable;
import javax.management.MBeanServer;
/*
* The author disclaims copyright to this source code. In place of
* a legal notice, here is a blessing:
*
* May you do good and not evil.
* May you find forgiveness for yourself and forgive others.
* May you share freely, never taking more than you give.
*
*/
package org.hibernate.dialect;