Skip to content

Instantly share code, notes, and snippets.

View stephenparish's full-sized avatar

Stephen Parish stephenparish

View GitHub Profile
@stephenparish
stephenparish / delete-merged.ps1
Last active October 16, 2017 15:21
Delete merged branches
git branch --merged | ?{-not ($_ -eq "* develop")} | %{git branch -d $_.trim()}
@stephenparish
stephenparish / submodule-pull.sh
Created July 15, 2014 15:03
Update submodules in a git repository to the latest, but exclude one..
git submodule foreach '[ "$path" == "submodule-to-exclude" ] || git pull origin master'
@stephenparish
stephenparish / SPAutoLayoutChildViewController.m
Last active December 26, 2015 04:39
Using auto layout with a child UIViewController
#import "SPAutoLayoutChildViewController.h"
@implementation SPAutoLayoutChildViewController
- (void)updateViewConstraints {
if (self.view.superview) {
UIView *thisView = self.view;
thisView.translatesAutoresizingMaskIntoConstraints = NO;
NSDictionary *views = NSDictionaryOfVariableBindings(thisView);
[self.view.superview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[thisView]|" options:0 metrics:nil views:views]];
@stephenparish
stephenparish / StoppableViewPager.java
Last active December 15, 2015 03:19
An easy to enable or disable view pager for Android
public class StoppableViewPager extends ViewPager {
private boolean mEnabled;
public StoppableViewPager(Context context) {
super(context);
mEnabled = true;
}
public StoppableViewPager(Context context, AttributeSet attrs) {
@stephenparish
stephenparish / examples.sh
Created February 9, 2012 20:23
SVN Partial Checkout
# checkout only immediate folders for a partial checkout
svn co http://subversion/project/trunk my_checkout --depth immediates
# change the depth and update
svn update --set-depth infinity
# another example
svn checkout --depth empty http://svnserver/trunk/ proj
svn update --set-depth infinity proj/foo
@stephenparish
stephenparish / noisy.js
Created January 31, 2012 19:43
Add a noise background to your site: Currently working for better non-grayscale support
function addNoise(canvas) {
var ctx = canvas.getContext('2d');
// get canvas pixels
var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
var pixels = imageData.data;
for (var i = 0, il = pixels.length; i < il; i += 4) {
// var color = Math.round(Math.random() * 255);
var M = 100;
@stephenparish
stephenparish / svn-cleaner.sh
Created November 9, 2011 00:07
Remove All SVN Folders -- When I have to clean up an old SVN checkout, I use this to remove the junk.
#!/bin/sh
echo "Recursively removing .svn folders from"
pwd
rm -rf `find . -type d -name .svn`
echo "Folders removed."
@stephenparish
stephenparish / gist:1349792
Created November 9, 2011 00:02
Less.js CSS Functions, some common short-hands I use to make my life easier.
// add rounded corners to an item
.border-radius (@radius: 5px) {
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
border-radius: @radius;
}
// add only specific rounded corners
.border-radius-all (@top: 5px, @right: 5px, @bottom: 5px, @left: 5px) {
-webkit-border-radius: @arguments;