Skip to content

Instantly share code, notes, and snippets.

View gcdr's full-sized avatar
😀
Better!

Glen Ritchie gcdr

😀
Better!
View GitHub Profile
@gcdr
gcdr / index.js
Created January 22, 2019 16:03 — forked from shortstuffsushi/index.js
Skip Google Music
// This script will monitor the Google Music page and skip songs you've already downvoted.
// Google doesn't do this automatically for some weird reason, so this hacks around that.
// Note that you're limited to somewhere around five skips per hour per station, so you
// can pretty quickly run into a scenario where this won't work. In the case that you want
// to stop the script, just run clearInterval(skipper) after this script.
var skipper = setInterval(function() {
// Grab the rating container (first of two with the same class)
var ratingContainer = document.getElementsByClassName('rating-container')[0];
@gcdr
gcdr / search-git-history.md
Created July 31, 2018 00:09 — forked from lyoshenka/search-git-history.md
Search Git commit history for a string and see the diffs

Searching Git commit history

This should be one of the core features of Git, but for some reason it's impossible to figure out how to search for a string in your commit history and see the diffs that that string is in. Here's the best I've come up with:

To find which commits and which files a string was added or removed in:

git log -S'search string' --oneline --name-status

To see the diff of that

@gcdr
gcdr / rpn.rkt
Created May 26, 2018 03:52 — forked from darkf/rpn.rkt
Racket pure-functional RPN calculator
#lang racket
(define (op? e)
(member e '(+ *)))
(define (op->procedure op)
(case op
[(+) +]
[(*) *]))
@gcdr
gcdr / one-liners.sh
Created May 12, 2018 03:46
A bunch of one (or very few) liners for Bash
# Get tweet, follower, and following information given a twitter username
twitterinfo() {
[[ -z "$1" ]] && echo "getthebird <username>" || curl -s https://twitter.com/$1 | awk 'BEGIN { tweets=""; following=""; followers=""; } /u-hiddenVisually.*Tweets, current page/ { if (length(tweets)==0) { getline; tweets=gensub(/^.*>(.*)/,"\\1","g",$0); } } /u-hiddenVisually.*Following/ { if(length(following)==0) { getline; following=gensub(/^.*>[ \t]*(.*)[ \t]*<.*$/,"\\1","g",$0); } } /u-hiddenVisually.*Followers/ { if(length(followers)==0) { getline; followers=gensub(/^.*>(.*)<.*$/,"\\1","g",$0); } } END { printf("@'"$1"' info:\n Tweets: %s\n Following: %s\n Followers: %s\n",tweets,following,followers); }'
}
# Get contents of an XML tag from standard input
getxmltag() {
[[ -z "$1" ]] && echo "usage: getxmltag <tag-name>" || (tr -d '\n' | sed 's/>[ \t]*</></g;s/^.*<'"$1"'>\(.*\)<\/'"$1"'>.*$/\1/g')
}
@gcdr
gcdr / .bashrc
Created March 13, 2018 19:24 — forked from mbround18/.bashrc
Personal bashrc
#--------------------------------------------------------------------------------------------
# if found on gist use `git clone https://gist.github.com/650d59476b86fbe885e66af953099006.git .`
# this is a modified version of Emmanuel Rouat [no-email] bashrc how to which can be found at
# `http://tldp.org/LDP/abs/html/sample-bashrc.html`
#--------------------------------------------------------------------------------------------
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
#-------------------------------------------------------------
@gcdr
gcdr / notepad.html
Created March 1, 2018 05:19 — forked from jdkanani/notepad.html
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">.e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div class="e" id="editor"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("editor");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
<!--
For other language: Instead of `ace/mode/ruby`, Use
Markdown -> `ace/mode/markdown`
Python -> `ace/mode/python`
C/C++ -> `ace/mode/c_cpp`
Javscript -> `ace/mode/javascript`
Java -> `ace/mode/java`
Scala- -> `ace/mode/scala`
@gcdr
gcdr / Join Line(S) with Emacs
Created February 27, 2018 19:55
Useful to reverse splitting of lines
;; -- define a new command to join multiple lines together --
(defun join-lines () (interactive)
(setq fill-column 100000)
(fill-paragraph nil)
(setq fill-column 78)
)
;; FROM: https://stackoverflow.com/questions/1072662/by-emacs-how-to-join-two-lines-into-one
;; Thank you Ralph. https://stackoverflow.com/users/23154/ralph
@gcdr
gcdr / text.adoc
Last active March 1, 2018 05:42
Testing ascii doc Format

The Article Title

This is the optional preamble (an untitled section body). Useful for writing simple sectionless documents consisting only of a preamble.

Note
The abstract, preface, appendix, bibliography, glossary and
@gcdr
gcdr / Vim Regex Replace
Last active May 4, 2020 20:22
Vim Regex Replace
%s/\(Date: \)\(.*\)/\1\2 Tags:/g
@gcdr
gcdr / OTH: Mathematica Plot Waves?
Last active June 22, 2016 00:26 — forked from Eckankar/waves.nb
Making wave animations in Mathematica
circleLine[x_, y_, s_] :=
Module[{d = 3/2*Sin[s + (x/2 + y)/10*Pi] + 3/2},
Graphics[
If[{x, y} == {7, 7}, {LightGray, Line[{{x, y}, {x + 3, y - 3}}],
Red}, {}]~Join~
{Circle[{x + d, y - d}, 0.1]}
]
];
frames = Table[