Skip to content

Instantly share code, notes, and snippets.

View DamianMullins's full-sized avatar
💭
👽

Damian Mullins DamianMullins

💭
👽
View GitHub Profile
@adiel
adiel / RestrictedFilesSpike.cs
Created July 13, 2011 12:19
Spike downloading files from behind login with Coypu
using System;
using System.IO;
using System.Net;
using Coypu;
using OpenQA.Selenium.Remote;
namespace Itv.BB.Bloom.Web.CMSSite.AcceptanceTests.Migration.Support
{
public static class CoypuExtensions
{
@ciscoheat
ciscoheat / gist:3004119
Created June 27, 2012 13:40
Classes for mocking HttpContext in ASP.NET MVC with Moq.
using System.Collections.Generic;
using System.Security.Principal;
using System.Web;
using Moq;
namespace Tests.Utils
{
public class HttpContextMock
{
public HttpContextMock(IEnumerable<KeyValuePair<string, string>> requestParams)
@benw
benw / load-hbs-partials.js
Created October 3, 2012 00:29
Loads partial handlebars templates from files in a directory
// Helps with this problem:
// http://stackoverflow.com/questions/8059914/express-js-hbs-module-register-partials-from-hbs-file
var hbs = require('hbs');
var fs = require('fs');
var partialsDir = __dirname + '/../views/partials';
var filenames = fs.readdirSync(partialsDir);
@jakeonrails
jakeonrails / Ruby Notepad Bookmarklet
Created January 29, 2013 18:08
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
@elijahmanor
elijahmanor / fake-server-unit-test.js
Last active August 28, 2018 09:23
Unit Test like a Secret Agent with Sinon.js
describe("getTweets - Server", function () {
var server, fakeData = [ /* ... */ ];
before(function () {
// Doesn’t work :( It’s JSONP!
server = sinon.fakeServer.create();
server.respondWith(
"GET",
"https://api.twitter.com/.../elijahmanor.json?count=5",
[200, { "Content-Type": "application/json" }, JSON.stringify(fakeData)]
@Integralist
Integralist / 1. Example Spec.js
Last active January 1, 2018 20:38
Mocking a Window object for unit-testing purposes
var mocks = {
resizeCalled: false,
createFakeWindow: function(width, height) {
var module = this;
return {
document: {
documentElement: {
clientWidth: width,
@antichris
antichris / about.md
Created October 21, 2013 14:55
Fork your own Gist

Fork your own Gist

This is a bookmarklet that adds a fully functional Fork button to your own Gist.

If a Fork button is already present in the page, this bookmarklet will set focus to it instead of adding another one.

The change is temporary and the button will disappear as soon as you navigate away from that Gist (clicking the Fork button does this for you as well).


@sindresorhus
sindresorhus / post-merge
Last active May 2, 2024 03:18
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
@staltz
staltz / introrx.md
Last active June 29, 2024 15:58
The introduction to Reactive Programming you've been missing
@paulallies
paulallies / gist:0052fab554b14bbfa3ef
Last active November 12, 2023 23:00
Remove node_modules from git repo
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin <branch-name>