Skip to content

Instantly share code, notes, and snippets.

View benmccallum's full-sized avatar

Ben McCallum benmccallum

View GitHub Profile
@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@asabaylus
asabaylus / gist:3071099
Created July 8, 2012 14:12
Github Markdown Heading Anchors

Anchors in Markdown

To create an anchor to a heading in github flavored markdown. Add - characters between each word in the heading and wrap the value in parens (#some-markdown-heading) so your link should look like so:

[create an anchor](#anchors-in-markdown)

@DiegoSalazar
DiegoSalazar / validate_credit_card.js
Last active February 21, 2025 13:22
Luhn algorithm in Javascript. Check valid credit card numbers
// Takes a credit card string value and returns true on valid number
function valid_credit_card(value) {
// Accept only digits, dashes or spaces
if (/[^0-9-\s]+/.test(value)) return false;
// The Luhn Algorithm. It's so pretty.
let nCheck = 0, bEven = false;
value = value.replace(/\D/g, "");
for (var n = value.length - 1; n >= 0; n--) {
@danielgreen
danielgreen / invalidHandler.UnobtrusiveValidation.js
Created May 29, 2013 14:02
When using jQuery Validate, you may want to run some code when it detects that the form is invalid. When using Unobtrusive Validation, you don't have the ability to set invalidHandler directly when initialising the Validate plugin, so here is a workaround.
// If using Unobtrusive Validation then that library initialised the Validate plugin
// on our behalf, so we missed the chance to set invalidHandler. Even if we were to
// set invalidHandler now via the settings object it would have no effect, due to the
// way that Validate works internally. Instead, we can do the following:
$("#MyForm").bind("invalid-form.validate", function () {
// Do something useful e.g. display the Validation Summary in a popup dialog
$("div.ValSummary").dialog({
title: "Information",
modal: true,
resizable: false,
@dmitrye
dmitrye / validate_credit_card.js
Last active February 1, 2018 16:42 — forked from DiegoSalazar/validate_credit_card.js
JavaScript Luhn validator method. Modifications made here include support for non-numeric characters in the value being cleaned up instead of rejecting the value. Also, cleaned up a duplicate variable and added identity check at the end instead of equality check.
// takes the form field value and returns true on valid number
function valid_credit_card(value) {
// The Luhn Algorithm. It's so pretty.
var nCheck = 0, bEven = false;
//this will remove all non-numeric characters and validate against remaining code.
//therefore this now supports 4111-1111-1111-1111 patterns as an example
value = value.replace(/\D/g, "");
for (var n = value.length - 1; n >= 0; n--) {
@iki
iki / README.md
Last active December 12, 2021 08:50 — forked from othiym23/npm-upgrade-bleeding.sh
Update global top level npm packages

Update global top level npm packages

Problem

npm update -g updates all global packages and their dependencies, see npm/npm#6247.

Solution

  1. Either use the shell script or windows batch here instead.
@patrickperrone
patrickperrone / ChangeSearchProvider.ps1
Last active November 2, 2017 11:00
This PowerShell script will change your Sitecore instance search provider from Lucene to Solr or vice versa.
function Get-ConfigFileFilter([string]$providerName)
{
return "^.*\." + $providerName + "\.(.+\.)?config.*$"
}
function Set-SCSearchProvider
{
$rootPath = Read-Host "What is the path of your Sitecore instance's website folder?";
$choice = Read-Host "(L)ucene or (S)olr?";
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active March 16, 2025 21:56
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

Param(
[string]$sourceRootPath
)
$paths=New-Object System.Collections.Generic.List[System.Object]
$paths.Add("C:\Program Files\nodejs")
$paths.Add("${HOME}\.dotnet\NuGetFallbackFolder")
$paths.Add("${HOME}\.nuget\packages")
$paths.Add("${HOME}\AppData\Local\Yarn")
$paths.Add("${HOME}\AppData\Roaming\npm")
@rajbos
rajbos / dotnetToolInstallCheck.ps1
Last active May 17, 2024 01:59
Use dotnet tool to find out if a specific tool is installed on an environment
# Preface:
# dotnet tool install -g will return an error code when the tool is already installed in the system (at the same location)
# adding a test like below, will prevent the error
# this is mostly needed in a CI/CD environment where you don't want to break your pipeline if the tool was installed already.
# find if stryker is installed
$list = (dotnet tool list -g)
# echo the list
# $list