Skip to content

Instantly share code, notes, and snippets.

View dfrencham's full-sized avatar

Danny Frencham dfrencham

  • Brisbane, Australia
View GitHub Profile
@dfrencham
dfrencham / console-colors.ts
Last active January 16, 2020 06:07
constants.ts
public static COLOR_RESET = '\x1b[0m';
public static COLOR_BRIGHT = '\x1b[1m';
public static COLOR_DIM = '\x1b[2m';
public static COLOR_UNDERSCORE = '\x1b[4m';
public static COLOR_BLINK = '\x1b[5m';
public static COLOR_REVERSE = '\x1b[7m';
public static COLOR_HIDDEN = '\x1b[8m';
public static COLOR_FGBLACK = '\x1b[30m';
public static COLOR_FGRED = '\x1b[31m';
@dfrencham
dfrencham / nifty-list-item-view.html
Created July 17, 2015 03:52
Knockout 3.3 Nested Components
<div style="border:1px solid blue; margin: 5px; padding: 5px;">
<label data-bind="text: labelText"></label>
<input type="text" />
</div>
@dfrencham
dfrencham / PrintDomRoleTree.js
Last active August 29, 2015 14:19
Print the DOM role tree
// Paste this in your Chrome/FireFox console
// The DOM accessibility tree will be printed
function getRoleTree() {
var tree = { text: "document", children: [] };
var dataTree = { 'core' : { 'data' : [ tree ]}};
var walk_the_DOM = function walk(node, tree, func) {
tree = func(node, tree);
@dfrencham
dfrencham / gist:605cdcc653f07bdd5a79
Created September 23, 2014 22:48
Find duplicate css classes in a file
# One liner!
# Finds all duplicate CSS classes in a CSS file, and ignores hex colour codes (the #DDDDDD pattern would be a false positve)
Get-Content .\filename.css | ForEach-Object { $_.Split(" ,.", [System.StringSplitOptions]::RemoveEmptyEntries) } | ForEach-Object { $_.Trim() } | where { ($_[0] -eq "#" -or $_[0] -eq "." ) -and (!$_.EndsWith(";")) } | where {$_ -notmatch '#[0-9a-fA-F]{2,}$'} | sort-object | group-object | where-object { $_.Count -gt 1 }
@dfrencham
dfrencham / gist:cfe658dc7cb983515847
Last active August 29, 2015 14:06
Regex to lower case all CSS attribute names
Sublime3 format.
Find: ( *)([A-Z0-9-]+)\:(.*)
Replace: $1\L$2: $4
@dfrencham
dfrencham / printBrowserPlugins.js
Created July 1, 2014 05:20
Print all browser plugins from browser console
for (i = 0; i < navigator.plugins.length; i++) { console.log(navigator.plugins[i].name + ' '); }