Skip to content

Instantly share code, notes, and snippets.

View cold-logic's full-sized avatar

Christopher Davison cold-logic

View GitHub Profile
@cold-logic
cold-logic / move.sh
Created November 7, 2022 23:29
Move a predefined list of files from one directory into another
#!/bin/bash
# Move files from one directory to another
# Usage: move.sh <filelist.txt> <source_dir> <destination_dir>
# Generate a filelist.txt using `ls > filelist.txt`
# First argument is the path to the filelist.txt that contains a newline separated (\n) list of filenames to move
txtListOfFilenames=$1
# Second argument is the path to the source directory where the files are currently located
@cold-logic
cold-logic / browser_chooser.desktop
Last active March 24, 2024 22:04
Browser Chooser for GNOME
[Desktop Entry]
Categories=GNOME;GTK;Network;WebBrowser;
Comment=Browser picker
Exec=$HOME/.bin/browser_chooser %U
GenericName=Web Browser
Icon=firefox
Keywords=Internet;WWW;Browser;Web;Explorer
Name=Browser Chooser
Type=Application
Version=1.0
@cold-logic
cold-logic / isempty.js
Last active March 5, 2020 21:32
Check a value and return true for null or undefined
// Exclude zero (0) which is typically falsy
let isEmpty = (x) => x == 0 ? false : !(x)
/* Tests (run in Node CLI)
> isEmpty(0)
false
> isEmpty(1)
false
> isEmpty(1.5)
false
@cold-logic
cold-logic / nightwatch-test.js
Created September 3, 2019 04:34
An E2E test using Nightwatch.js
module.exports = {
'Demo test Ecosia.org': function (browser) {
browser
.url('https://www.ecosia.org/')
.waitForElementVisible('body')
.assert.titleContains('Ecosia')
.assert.visible('input[type=search]')
.setValue('input[type=search]', 'nightwatch')
.assert.visible('button[type=submit]')
.click('button[type=submit]')
@cold-logic
cold-logic / unique-array.js
Created January 22, 2019 06:24
Performant JS Filter Array Unique
// benchmarked in milliseconds against an array of 7 million members
// safari 12 = 79
// chrome 67 = 115
// node 10 = 97
arrFilter = (arr) => {
return arr.filter((elem, pos, array) => {
// if the element's index in array doesn't equal pos, it will be added
return array.indexOf(elem) == pos
})
@cold-logic
cold-logic / vscode-extensions.md
Last active January 28, 2024 02:44
My favorite VS Code extensions
  • Code Runner - Run code directly and pipe output into the terminal.
  • Cobalt2 Theme - Dark blue with vibrant colors
  • Better Align - Align code intent using a specific delimiter
  • Indent Guides - Improves visibility of where you are in indented code blocks
    • Add the following to your User Settings to style the guides:
    // Guides extension
    "guides.overrideDefault": true,
    "guides.sendUsagesAndStats": false,
    

"guides.active.width": 2,

@cold-logic
cold-logic / Humble-Bundle-Games.js
Last active December 6, 2019 22:51
Copies a list of humble bundle games into your clipboard for inventory managment
/*
* Copies a list of humble bundle games into your clipboard for inventory managment
* Designed for the receipt/download pages:
* https://www.humblebundle.com/downloads?key={key}
*/
{
console.clear()
// Feel free to customize these tags as you wish
const tags = ['#Humble'].join(' ')
// DOM query selectors
@cold-logic
cold-logic / Humble-Bundle-Books.js
Created October 24, 2017 01:16
Export a list of Humble Bundle eBooks
{
let a = [], b // Setup local vars
console.clear() // Clear the console
// For each item
$(".gameinfo").each(function() {
// Get the title & subtitle
let title = $(this).find('.title').text().trim()
let subtitle = $(this).find('.subtitle').text().trim()
a.push(`${title} - ${subtitle} #Humble`)
// Add the download URLs
@cold-logic
cold-logic / discogs-tracklist-batch-import.js
Created October 9, 2017 18:38
Discogs Tracklist Batch Import
/**************************************************
* Discogs Tracklist Batch Import
**************************************************
* Takes a tab separated list of values
* from Excel or Pages and feeds them into
* the discogs tracklist page
**************************************************/
function fill(a) {
// Get a list of table rows from the tracklist

Keybase proof

I hereby claim:

  • I am cold-logic on github.
  • I am christopherd (https://keybase.io/christopherd) on keybase.
  • I have a public key whose fingerprint is D34C D8CD FD1A 3360 9A11 C9E2 F40D 71A2 C4C1 4D58

To claim this, I am signing this object: