Skip to content

Instantly share code, notes, and snippets.

View DavidMetcalfe's full-sized avatar

David Metcalfe DavidMetcalfe

  • Canada
  • 22:17 (UTC -07:00)
View GitHub Profile
@DavidMetcalfe
DavidMetcalfe / git-init-repo-from-dir
Created February 12, 2017 00:03 — forked from nanusdad/git-init-repo-from-dir
GitHub - initialize from existing directory
Create the remote repository, and get the URL such as
git@github.com:/youruser/somename.git or https://github.com/youruser/somename.git
If your local GIT repo is already set up, skips steps 2 and 3
Locally, at the root directory of your source, git init
Locally, add and commit what you want in your initial repo
#The MIT License (MIT)
# Copyright (c) 2012 Jordan Wright <jordan-wright.github.io>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@DavidMetcalfe
DavidMetcalfe / ControlSoundWindows.ahk
Last active April 7, 2017 17:55
Repurpose F11 and F12 keys to control sound in Windows
F11::
; Decremenet sound by 10.
{
SoundSet -10
return
}
F12::
; Increment sound by 10.
{
@DavidMetcalfe
DavidMetcalfe / findOne.js
Last active April 8, 2017 18:43
Find match between string and array, stop after first positive result
/**
* @description determine if an array contains one or more items from another array.
* @param {array} needle the array providing items to check for in the haystack.
* @param {array} haystack the array to search.
* @return {boolean} true|false if haystack contains at least one item from arr.
*/
var findOne = function (needle, haystack) {
return needle.some(function (v) {
return haystack.indexOf(v) >= 0;
});
@DavidMetcalfe
DavidMetcalfe / PennyRound.ahk
Created April 8, 2017 19:30
AutoHotkey function to perform penny rounding
pennyRound(val)
{
;Performs penny rounding on inputted float, and
;returns calculated amount.
sub := SubStr(val, 0, 1)
subMult := round((sub * 0.01), 2)
if (subMult <= 0.02) {
price := round((val - subMult), 2)
@DavidMetcalfe
DavidMetcalfe / .gitignore
Last active April 8, 2017 21:40
Generalized .gitignore file for Python projects with emphasis on ignoring packaging and OS files. Original taken from https://github.com/github/gitignore
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# celery beat schedule file
celerybeat-schedule
@DavidMetcalfe
DavidMetcalfe / FizzBuzz_OneLiner.py
Created May 27, 2017 20:58
FizzBuzz One-liner for Python3
print('\n'.join("Fizz" * ( i % 3 == 0) + "Buzz" * ( i % 5 == 0) or str(i) for i in range(1, 101)))
@DavidMetcalfe
DavidMetcalfe / Excel_VBA_AutoFilter_Criteria.txt
Created March 11, 2018 04:19
Various permutations of negative matching in Excel VBA
ActiveSheet.Range("Database").AutoFilter Field:=1, Criteria1:="=NULL", Operator:=xlAnd 'EQUALS "NULL"
'ActiveSheet.Range("Database").AutoFilter Field:=1, Criteria1:="<>NULL", Operator:=xlAnd 'DOES NOT EQUAL "NULL"
'ActiveSheet.Range("Database").AutoFilter Field:=1, Criteria1:="=NULL*", Operator:=xlAnd 'BEGINS WITH "NULL"
'ActiveSheet.Range("Database").AutoFilter Field:=1, Criteria1:="<>NULL*", Operator:=xlAnd 'DOES NOT BEGIN WITH "NULL"
'ActiveSheet.Range("Database").AutoFilter Field:=1, Criteria1:="=*NULL", Operator:=xlAnd 'ENDS WITH "NULL"
'ActiveSheet.Range("Database").AutoFilter Field:=1, Criteria1:="<>*NULL", Operator:=xlAnd 'DOES NOT END WITH "NULL"
'ActiveSheet.Range("Database").AutoFilter Field:=1, Criteria1:="=*NULL*", Operator:=xlAnd 'CONTAINS "NULL"
'ActiveSheet.Range("Database").AutoFilter Field:=1, Criteria1:="<>*NULL*", Operator:=xlAnd 'DOES NOT CONTAIN "NULL"
'ActiveSheet.Range("Database").AutoFilter Field:=1, Criteria1:="=" 'Blanks
'Active
@DavidMetcalfe
DavidMetcalfe / Recursive search through files.sh
Last active April 19, 2018 23:19
Recursively search through files in chosen directory
# -r = recursive
# -n = line number within file
# -w = match whole word
grep -rnw . -e 'query' # Search current dir in bash.
grep -rnw '/path/to/directory/' -e 'query' # Search provided directory in bash.
@DavidMetcalfe
DavidMetcalfe / autoclicker.js
Last active May 1, 2018 01:48
Cookie Clicker Auto Clicker (Click Spammer)
// [ === Toggleable autoclicker === ]
// Activating will enable, and a second toggle will deactivate.
// ** Legit version (doesn't activate Game.autoclickerDetected)
if (window._activeClickInterval) {
clearInterval(window._activeClickInterval);
delete window._activeClickInterval;
} else {
window._activeClickInterval = setInterval(Game.ClickCookie, 250);
}