Skip to content

Instantly share code, notes, and snippets.

View rpocklin's full-sized avatar

Robert Pocklington rpocklin

View GitHub Profile
@rpocklin
rpocklin / ng-comments.html
Created July 1, 2014 01:31
AngularJS Comments which will be removed from production code
<div ng-if="false">
<!--
Here is a comment which will not be shown in production code.
-->
</div>
@rpocklin
rpocklin / gist:09efefdb97c129c07d18
Created August 25, 2014 06:50
How to skip manually trusting new hosts for VMs
Set StrictHostKeyChecking no in your ~/.ssh/config file, where it will be the default for only the current user. Or you can use it on the command line:
ssh -o StrictHostKeyChecking=no -l $user $host
@rpocklin
rpocklin / include-directive.js
Last active August 29, 2015 14:05
Angular directive which permits re-use for content referring to scope variables.
'use strict';
/**
* An ng-include replacement which transparently inherits the parent scope and also allows local customisation of variables
* within the snippet.
*
* Designed to use $templateCache (in production) and fallback to an AJAX request (for dev-mode) to load view templates.
*
* Use as below (can customise variables used in the snippet via ng-init):
* <div include="'users/_password_confirmation_input.html'" ng-init="placeholder = 'Re-enter Password'"></div>
@rpocklin
rpocklin / docs.sh
Created October 17, 2014 13:25
Make rspec_api_documentation with apitome generate static HTML documentation (dirty but it works).
#!/bin/bash
wget -m http://localhost:3000/api/docs
mv localhost\:3000/ api-documentation
mv ./api-documentation/api/docs ./api-documentation/api/docs.html
@rpocklin
rpocklin / word.rb
Created August 22, 2011 23:19
simplifying code (from Java to groovy or ruby)
Ruby / Groovy
def get_types
words.collect{|word| word.word_type}
end
15 seconds to code.
3 seconds to read and understand.
Easy to read = self documenting.
Less LOC = better codebase and more agile team.
@rpocklin
rpocklin / memoize_class_example.rb
Created March 6, 2012 02:01
memoizing a class method in ruby
require 'active_support'
## strange this isn't done implicitly
class A
class << self
extend ActiveSupport::Memoizable
def my_class_method(x)
# cool stuff here
@rpocklin
rpocklin / confirm_process_not_running.sh.sh
Created September 7, 2012 06:10
Shows the number of processes running given a grep <string> and exit 1 if still running.
#!/bin/bash
let "RESULT=$(ps ax | grep $1 | wc -l) - 1" ;echo "$RESULT processes found for $1."; if [ "$RESULT" == 0 ]; then exit 0; else exit 1;fi;
@rpocklin
rpocklin / remove_svn_folders.sh
Created September 19, 2012 02:20
Removes horrible .svn directories from current path (and recurses) so that you can move them safely into folders as new files to be checked in
rm -rf `find . -type d -name .svn`
@rpocklin
rpocklin / gist:5156541
Created March 13, 2013 21:35
coerce a single or array parameter into array - keeping args flexible
def some_method(single_or_array)
single_or_array = [*single_or_array]
# do awesome stuff here...
end
$("#e2").select2({
placeholder: "Select a State",
allowClear: true
});