Skip to content

Instantly share code, notes, and snippets.

Avatar

Gautam Singh gtmsingh

View GitHub Profile
View typeracer.hack.js
function triggerKeyboardEvent(el, keyCode, type)
{
var eventObj = document.createEventObject ?
document.createEventObject() : document.createEvent("Events");
if(eventObj.initEvent){
eventObj.initEvent(type, true, true);
}
eventObj.keyCode = keyCode;
@carlsmith
carlsmith / replace.py
Created Apr 5, 2017
A Python function that does multiple string replace ops in a single pass.
View replace.py
import re
def replace(string, substitutions):
substrings = sorted(substitutions, key=len, reverse=True)
regex = re.compile('|'.join(map(re.escape, substrings)))
return regex.sub(lambda match: substitutions[match.group(0)], string)
@mobilemind
mobilemind / git-tag-delete-local-and-remote.sh
Last active Mar 5, 2021
how to delete a git tag locally and remote
View git-tag-delete-local-and-remote.sh
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName