Skip to content

Instantly share code, notes, and snippets.

View roryf's full-sized avatar

Rory Fitzpatrick roryf

  • Edinburgh, Scotland
View GitHub Profile
@roryf
roryf / subject.js
Last active August 29, 2015 14:11
How do I test this?
module.exports = function(input, output, cb) {
input.on('data', function(chunk) {
// do somethink with chunk, possibly transform it
output.write(chunk);
});
input.on('end', function() {
cb();
});
};

Keybase proof

I hereby claim:

  • I am roryf on github.
  • I am roryf (https://keybase.io/roryf) on keybase.
  • I have a public key whose fingerprint is 8C61 087D 15AC F592 C929 D9A2 AE01 0AE3 B6CE 9946

To claim this, I am signing this object:

@roryf
roryf / controller_decorator.js
Created December 11, 2013 10:29
Proof of concept to allow ui-router resolvers to also apply when controllers are created via ng-controller directive.
angular.module('ui.router').config(['$provide', function($provide) {
$provide.decorator('$controller', [
'$delegate', '$state',
function($delegate, $state) {
return function(expression, locals) {
if ($state.$current) {
locals = _.extend(locals, $state.$current.locals.globals);
}
return $delegate(expression, locals);
@roryf
roryf / this.js
Created November 20, 2013 00:20
Pop quiz
var one = {
name: 'one',
hello: function() {
console.log(this.name);
}
};
var two = {
name: 'two'
};
@roryf
roryf / Example.cs
Created February 13, 2013 12:47
Object extension method to peek at a private field. Useful when testing an against an object which has state but will not actually execute anything. See example using NSubstitute.
repository.Query(Arg.Is<FindUserByEmailQuery>(x => x.PeekPrivateField("emailAddress") == "foo@bar.com")).Returns(user);
@roryf
roryf / tabs.html
Created December 4, 2012 11:21
Better tabs
<div class="responsive-tabs">
<section class="tab-panel">
<h2 class="tab-anchor">Item 1</h2>
<div class="tab-content">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras tincidunt pellentesque lorem, id suscipit dolor rutrum id. Morbi facilisis porta volutpat. Fusce adipiscing, mauris quis congue tincidunt, sapien purus suscipit odio, quis dictum odio tortor in sem. Ut sit amet libero nec orci mattis fringilla. Praesent eu ipsum in sapien tincidunt molestie sed ut magna. Nam accumsan dui at orci rhoncus pharetra tincidunt elit ullamcorper. Sed ac mauris ipsum. Nullam imperdiet sapien id purus pretium id aliquam mi ullamcorper.</p>
</div>
</section>
<section class="tab-panel">
@roryf
roryf / .gitignore
Created July 5, 2012 14:08
.gitignore for working with Visual Studio
build/
release/
package/
*.suo
*.user
bin
!/bin
obj
_ReSharper*
*.csproj.user
@roryf
roryf / IndexlessEnumerableModelBinder.cs
Created March 29, 2012 16:09
An ASP.NET MVC ModelBinder for binding form values of the form name[].property rather than name[index].property. Assumes form values are POSTed in markup order, unsure if this is always true.
public class IndexlessEnumerableModelBinder<TItemType> : DefaultModelBinder
where TItemType : class
{
protected override void BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor)
{
if (typeof(IEnumerable<TItemType>).IsAssignableFrom(propertyDescriptor.PropertyType))
{
var nameOfPropertyToBind = propertyDescriptor.Name;
var form = controllerContext.HttpContext.Request.Form;
@roryf
roryf / gist:2214167
Created March 27, 2012 09:00
Umbraco SQL query for AncestorContentOrSelf
SELECT this_.Id as Id16_9_,
this_.DateCreated as DateCrea2_16_9_,
this_.DefaultName as DefaultN3_16_9_,
this_.AttributeSchemaDefinition_id as Attribut4_16_9_,
this_.NodeId as NodeId16_9_,
attribalia3_.NodeVersionId as NodeVers3_11_,
attribalia3_.Id as Id11_,
attribalia3_.Id as Id5_0_,
attribalia3_.AttributeDefinitionId as Attribut2_5_0_,
attribalia3_.NodeVersionId as NodeVers3_5_0_,
@roryf
roryf / gist:1848769
Created February 16, 2012 23:33
brew install git
==> Downloading http://git-core.googlecode.com/files/git-1.7.9.1.tar.gz
File already downloaded in /Users/rory/Library/Caches/Homebrew
/usr/bin/tar xf /Users/rory/Library/Caches/Homebrew/git-1.7.9.1.tar.gz
==> make prefix=/usr/local/Cellar/git/1.7.9.1 CC=/Applications/Xcode.app/Contents/Developer/usr/bin/llvm-gcc CFLAGS=-Os -w -pipe -march=core2 -msse4.1 LDFLAGS= install
make prefix=/usr/local/Cellar/git/1.7.9.1 CC=/Applications/Xcode.app/Contents/Developer/usr/bin/llvm-gcc CFLAGS=-Os -w -pipe -march=core2 -msse4.1 LDFLAGS= install
GIT_VERSION = 1.7.9.1
* new build flags or prefix
* new link flags
./generate-cmdlist.sh > common-cmds.h+ && mv common-cmds.h+ common-cmds.h
/Applications/Xcode.app/Contents/Developer/usr/bin/llvm-gcc -o hex.o -c -MF ./.depend/hex.o.d -MMD -MP -Os -w -pipe -march=core2 -msse4.1 -I. -DUSE_ST_TIMESPEC -DNO_GETTEXT -DHAVE_DEV_TTY -DSHA1_HEADER='<openssl/sha.h>' -DNO_MEMMEM hex.c