Skip to content

Instantly share code, notes, and snippets.

View matthewbordas's full-sized avatar

Matt Bordas matthewbordas

View GitHub Profile
@reinvanoyen
reinvanoyen / terminal-prompt-git-branch-zsh.md
Last active April 30, 2024 21:16
Add Git Branch Name to Terminal Prompt (MacOS zsh)

Add Git Branch Name to Terminal Prompt (zsh)

Updated for MacOS with zsh

  • Catalina
  • Big Sur
  • Monterey
  • Ventura
  • Sonoma

screenshot

@JoeFerrucci
JoeFerrucci / tableViewContentHeight.swift
Last active July 21, 2016 23:07
Finding the height of your UITableView's current content.
/////////////////////////////////////////////////////////////////////
// finding the height of your UITableView's current content:
/////////////////////////////////////////////////////////////////////
let tableView = UITableView()
func contentHeight(forTableView tableView: UITableView) -> CGFloat {
let lastSectionIndex = tableView.numberOfSections - 1
let lastRowIndex = tableView.numberOfRowsInSection(lastSectionIndex)
@JoeFerrucci
JoeFerrucci / gist:31f76ad0c22d1b43bcd968f2dcd46780
Created July 21, 2016 00:44
map a range of values to a different range of values.
private func mapValueToRange(value: CGFloat, largerRangeMin: CGFloat, largerRangeMax: CGFloat, targetRangeMin: CGFloat, targetRangeMax: CGFloat) -> CGFloat {
let largerSpan = largerRangeMax - largerRangeMin
let targetSpan = targetRangeMax - targetRangeMin
// Scaled to 0-1 range.
var scaleBy = (value - largerRangeMin) / largerSpan
if scaleBy < 0 { scaleBy = 0 }
if scaleBy > 1 { scaleBy = 1 }
@harto
harto / before.js
Created April 20, 2016 17:33
Mocha before() & beforeEach() execution order with nested describe()
'use strict';
describe('mocha before hooks', function () {
before(() => console.log('*** top-level before()'));
beforeEach(() => console.log('*** top-level beforeEach()'));
describe('nesting', function () {
before(() => console.log('*** nested before()'));
beforeEach(() => console.log('*** nested beforeEach()'));
it('is a nested spec', () => true);
});
@jcefoli
jcefoli / guid.ps1
Created February 17, 2016 14:45
Create GUID in Powershell (Uppecase String)
[guid]::NewGuid().toString().ToUpper()
@mbbx6spp
mbbx6spp / ALTERNATIVES.adoc
Last active April 25, 2024 15:14
Super quick list of alternatives to Jira and/or Confluence, Stash, Crucible, etc.
@hansifer
hansifer / URL regex for JS
Created June 24, 2015 01:19
JavaScript port of URL regex from http://stackoverflow.com/a/190405/384062, including a bug fix and some performance refactoring
/^[a-z](?:[-a-z0-9\+\.])*:(?:\/\/(?:(?:%[0-9a-f][0-9a-f]|[-a-z0-9\._~!\$&'\(\)\*\+,;=:\xA0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[\uD800-\uD83E\uD840-\uD87E\uD880-\uD8BE\uD8C0-\uD8FE\uD900-\uD93E\uD940-\uD97E\uD980-\uD9BE\uD9C0-\uD9FE\uDA00-\uDA3E\uDA40-\uDA7E\uDA80-\uDABE\uDAC0-\uDAFE\uDB00-\uDB3E\uDB44-\uDB7E][\uDC00-\uDFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F][\uDC00-\uDFFD])*@)?(?:\[(?:(?:(?:[0-9a-f]{1,4}:){6}(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(?:\.(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3})|::(?:[0-9a-f]{1,4}:){5}(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(?:\.(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3})|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(?:\.(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3})|(?:[0-9a-f]{1,4}:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}(?:[
using System.ComponentModel;
using System.Globalization;
using System.Resources;
using System.Windows.Data;
public class TranslationSource
: INotifyPropertyChanged
{
private static readonly TranslationSource instance = new TranslationSource();
@brock
brock / nodereinstall.sh
Last active April 17, 2024 08:26
Complete Node Reinstall. I've moved this to a repo at http://git.io/node-reinstall
#!/bin/bash
# node-reinstall
# credit: http://stackoverflow.com/a/11178106/2083544
## program version
VERSION="0.0.13"
## path prefix
PREFIX="${PREFIX:-/usr/local}"