Skip to content

Instantly share code, notes, and snippets.

@bpugh
bpugh / pre-push
Created Jan 10, 2018 — forked from jgosmann/pre-push
Prevent pushing fixup, squash, and WIP commits to master.
View pre-push
#!/bin/sh
# An example hook script to verify what is about to be pushed to master. Called
# by "git push" after it has checked the remote status, but before anything has
# been pushed. If this script exits with a non-zero status nothing will be
# pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
@bpugh
bpugh / extensions.js
Created Aug 24, 2017
My VS Code recommended extensions
View extensions.js
{
// Recommended extensions for VS Code
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
// Extension identifier format: ${publisher}.${name}.
"formulahendry.auto-close-tag",
"formulahendry.auto-rename-tag",
"EditorConfig.EditorConfig",
"dbaeumer.vscode-eslint",
@bpugh
bpugh / pre-commit
Created Jan 11, 2017
Git example pre-commit hook
View pre-commit
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
@bpugh
bpugh / npm_proxy_auth.ps1
Created Jul 28, 2016
Powershell wrapper function around npm to prompt for password for http proxy
View npm_proxy_auth.ps1
function np {
$response = Read-host "Enter password" -AsSecureString
$password = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($response))
$un = [Environment]::Username
$proxy = "http://${un}:${password}@proxy/"
npm $args --proxy $proxy
}
View example1.js
export default function(file, api) {
const j = api.jscodeshift;
const {expression, statement, statements} = j.template;
const convertToTemplateString = p => {
const quasis = [
j.templateElement({ cooked: '', raw: ''}, false),
j.templateElement({ cooked: '', raw: ''}, false),
j.templateElement({ cooked: '', raw: ''}, true)
]
@bpugh
bpugh / kata.md
Last active Aug 29, 2015
Mars rover kata
View kata.md

The Mars Rover kata Explanation

  • Develop an api that moves a rover around a grid.
  • You are given the initial starting point (x,y) of a rover and the direction (N,S,E,W) it is facing.
  • The rover receives a character array of commands.
  • Implement commands that move the rover forward/backward (f,b).
  • Implement commands that turn the rover left/right (l,r).
  • The only commands you can give the rover are f,b,l, and r.
  • Implement wrapping from one edge of the grid to another. (planets are spheres after all)
  • Implement obstacle detection before each move to a new square. If a given sequence of commands encounters an obstacle, the rover moves up to the last possible point and reports the obstacle.
@bpugh
bpugh / EditableText.jsx
Created Jul 2, 2015
react inline edit component
View EditableText.jsx
var React = require('react');
var EditableText = React.createClass({
propTypes: {
onSubmit: React.PropTypes.func.isRequired
,validator: React.PropTypes.func
,enableEditing: React.PropTypes.bool
,value: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number,
View README.md

This is an example command for Backtick. A Backtick command consists of some executable JavaScript and a bit of metadata in JSON.

Here are the required steps to create a command:

  1. Create a new Gist with a command.js and command.json file, or simply fork this one.

  2. Write your JavaScript in command.js. This will be injected into and executed on the page the user is currently on when they run it.

  3. Add some metadata to the command.json file:

  • name: The name of the command.
@bpugh
bpugh / mancalaKata.cs
Created Mar 27, 2012
thomas, brandon, matt kata
View mancalaKata.cs
using NSpec;
namespace MancalaKata
{
class describe_MancalaGame : nspec
{
Well well1;
Well well2;
Well well3;
Well well4;