Skip to content

Instantly share code, notes, and snippets.

View benvium's full-sized avatar

Ben Clayton benvium

  • www.calvium.com
  • Bristol, UK
View GitHub Profile
@benvium
benvium / adblock
Created November 15, 2014 12:37
adblock plus - custom filter to hide annoying 'hot network questions' and 'featured on meta' boxes. To install, go to Abblock / options / customize / edit and paste these lines in
stackoverflow.com###hot-network-questions
stackoverflow.com##div.community-bulletin
@benvium
benvium / git-code-file-changes.sh
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 http://stackoverflow.com/questions/2528111/how-can-i-calculate-the-number-of-lines-changed-between-two-commits-in-git
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)}'
#import <UIKit/UIKit.h>
@interface UIImage (AddtionalFunctionalities)
//TintColor...
- (UIImage *)imageWithTint:(UIColor *)tintColor;
//scale and resize...
-(UIImage*)scaleToSize:(CGSize)size;
@end
@benvium
benvium / side-by-side-phabriactor-wiki-editor.css
Last active August 19, 2021 19:30
Userstyle for Phabricator Wiki to enable Side-by-side editing, and to hide loads of unused stuff.Use Patterns: https://*/phriction/edit/*
/* SIDE BY SIDE PHRICTION EDIT */
/* add a userstyle with pattern */
/* L H S */
/* pos of left-hand editor */
.phui-box.phui-box-border.mlt.mll.mlr.phui-object-box.phui-object-box-lightblue {
margin-right: 800px !important;
margin-left:0 !important;
@benvium
benvium / command.sh
Created September 30, 2014 15:49
bash command line parameters and usage help
#!/bin/sh
if [ $# -ne 2 ]; then
echo "Usage: $0 (first parameter) (second parameter) e.g. $0 foo bar";
exit 1;
fi
foo=$1
bar=$2
@benvium
benvium / run_on_main_thread.java
Created September 9, 2014 14:25
Run a piece of code on the main thread.
new Handler(Looper.getMainLooper()).post(new Runnable() {
// stuff for main thread
});
@benvium
benvium / DynamicColorRoundedRectDrawable.java
Created September 3, 2014 20:41
Programatically create a clickable, disableable, drawable with rounded corners, where the color doesn't have to be known at compile-time. If your color is fixed, then it's easy to use XML to do this, but if the color is completely dynamic this is a good option.
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.util.StateSet;
import android.view.View;
@benvium
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
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
// http://stackoverflow.com/questions/25126295/swift-class-does-not-implement-its-superclasss-required-members
}
@benvium
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"
}