Skip to content

Instantly share code, notes, and snippets.

View benvium's full-sized avatar

Ben Clayton benvium

  • Bristol, UK
View GitHub Profile
benvium / 0_reuse_code.js
Created August 21, 2014 11:01
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
benvium /
Created August 29, 2014 19:25
Programatically create a drawable with rounded corners
public class RRDrawable extends Drawable {
private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
public RRDrawable(int color) {
public void draw(Canvas canvas) {
benvium / [swift]enum-range-printable.swift
Last active August 29, 2015 14:05
Apple Swift: String enums, switch ranges, Printable protocol (description property)
// Playground - noun: a place where people can play
import UIKit
enum State : String {
case ASLEEP = "asleep",
AWAKE = "awake",
DRUNK = "drunk"
benvium / MyCellSubclass.swift
Created August 30, 2014 19:11
Minimal Swift TableViewController with very basic datasource from a literal array
class MyCellSubclass: UITableViewCell {
@IBOutlet var myNameLabel: UILabel!;
@IBOutlet var myOtherLabel: UILabel!;
// Do not include any inits, or we need to implement
// the required init outself
benvium / build.txt
Last active August 29, 2015 14:05
add signing using keystore file to an android build.gradle file
android {
compileSdkVersion ...
// Note this section MUST appear before 'buildTypes' in the build.gradle file.
signingConfigs {
release {
storeFile file("filename.keystore")
storePassword "password"
benvium /
Created September 30, 2014 15:49
bash command line parameters and usage help
if [ $# -ne 2 ]; then
echo "Usage: $0 (first parameter) (second parameter) e.g. $0 foo bar";
exit 1;
#import <UIKit/UIKit.h>
@interface UIImage (AddtionalFunctionalities)
- (UIImage *)imageWithTint:(UIColor *)tintColor;
//scale and resize...
benvium /
Created October 16, 2014 08:58
Git command to list number of changes to .h and .m files in the last month by a particular user Extension of
git log --numstat --author="Ben Clayton" --since "1 month" -- *.m *.h | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d, -%d\n", plus, minus)}'
benvium / CustomLogFormatter.h
Last active August 29, 2015 14:12
CocoaLumberjack Custom Log Formatter with time, log level, filename, line number, selector and message. The code `DDLogDebug(@"Enabled notification for status characteristic");` will write to the console: `12:19:13:539 V: DeviceConnector.m:101 bt_onConnected: | Enabled notification for status characteristic`
// Created by Ben Clayton on 23/12/14.
// Copyright (c) 2014 Calvium Ltd. All rights reserved.
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "DDLog.h"
@interface CustomLogFormatter : NSObject<DDLogFormatter>
benvium / NSPointerArray+CALCompact.h
Created February 10, 2015 17:25
NSPointerArray compact method that actually works.
#import <Foundation/Foundation.h>
@interface NSPointerArray (CALCompact)
- (void)cal_compact;