Skip to content

Instantly share code, notes, and snippets.

@bpugh
bpugh / prettyify.js
Created September 7, 2023 01:42
Prettyify pages on https://chordsworld.com for printing
const hero = document.querySelector('.hero-container');
const content = document.querySelector('.entry-content');
document.body.innerHTML = '';
document.body.appendChild(hero);
document.body.appendChild(content);
document.body.innerHTML+= "I ❤️ Chris";
@bpugh
bpugh / pre-push
Created January 10, 2018 17:46 — forked from jgosmann/pre-push
Prevent pushing fixup, squash, and WIP commits to master.
#!/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 August 24, 2017 20:03
My VS Code recommended extensions
{
// 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 January 11, 2017 19:45
Git example pre-commit hook
#!/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 July 28, 2016 21:34
Powershell wrapper function around npm to prompt for password for http proxy
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
}
@bpugh
bpugh / example1.js
Created February 8, 2016 17:22
blog post test
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 August 29, 2015 14:24
Mars rover kata

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 July 2, 2015 20:53
react inline edit component
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,
@bpugh
bpugh / README.md
Last active December 29, 2015 09:59 — forked from JoelBesada/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 March 27, 2012 01:37
thomas, brandon, matt kata
using NSpec;
namespace MancalaKata
{
class describe_MancalaGame : nspec
{
Well well1;
Well well2;
Well well3;
Well well4;