Skip to content

Instantly share code, notes, and snippets.

View oaustegard's full-sized avatar
👻
mostly lurking

Oskar Austegard oaustegard

👻
mostly lurking
View GitHub Profile
javascript:$("ul.nav-pills a")[1].click(); $("#route_from input.query").attr("value", "your from address"); $("#route_to input.query").attr("value", "your to address"); $("button.find-routes-btn").click();
@oaustegard
oaustegard / scalding_alice.scala
Last active August 29, 2015 14:27 — forked from johnynek/scalding_alice.scala
Learn Scalding with Alice
/**
Get the last line of text in Alice in Wonderland that contains each of the top 20 frequent words in the book
NOT ACTUALLY TESTED, just logically combined. See fork source for original version that is mulch ore likely to work.
*/
import scala.io.Source
val alice = Source.fromURL("http://www.gutenberg.org/files/11/11.txt").getLines.zipWithIndex.toList
val aliceWords = TypedPipe.from(alice).flatMap { case (text, _) => text.split("\\s+").toList }
val wordCount = aliceWords.map { word => (word, 1L) }.group.sum
val top20 = wordCount.groupAll.sortBy { case (word, count) => -count }.take(20).values
val lastLine = alicePipe.flatMap { case (text, line) => text.split("\\s+").toList.map { word => (word, line) }}.group.max
@oaustegard
oaustegard / ConfluenceHeaderFragmentLinks.js
Last active February 18, 2019 22:14
Simple JS code for adding links to all headers on a Confluence page
@oaustegard
oaustegard / gciData_datalayer.js
Last active April 9, 2020 04:22
Opens a new window to reveal the data layer on any Gannett site
if(typeof gciData !== "undefined" && gciData && gciData[0]) {
var w, d;
w = window.open('about:blank','','width=900,height=700,resizeable,scrollbars');
d = w.document;
d.writeln('<title>gciData[0] Data Layer: ', location.href, '</title>');
d.writeln('<style>td {vertical-align:top; font:9pt courier; border-bottom:1px solid #ddd}</style><table>');
//sort the keys and only write out the non-objects
Object.entries(gciData[0]).sort((a, b) => a[0].localeCompare(b[0])).forEach(([key, value]) => {
if (typeof value !== "object")
d.writeln('<tr><td>', key, '</td><td>', value, '</td></tr>')
@oaustegard
oaustegard / gsuite_shortcuts.js
Last active April 9, 2020 02:19
Bookmarklets to create new GSuite documents - unbelievably simple, but used ALLthe time
//docs
javascript:window.open("https://docs.new");
//sheets
javascript:window.open("https://sheets.new");
@oaustegard
oaustegard / video_speed.js
Created April 9, 2020 02:26
Change the playback speed of video - useful for things like mandated training videos that don't allow fast forwarding
javascript:(function(s){document.querySelector('video').playbackRate = s;})(prompt('Video speed:'));
@oaustegard
oaustegard / Link_to_Nearest_ID.js
Last active April 9, 2020 04:52
Generates a "deep" or document fragment link to the nearest element with an id above the selected text
@oaustegard
oaustegard / edit_page.js
Created April 9, 2020 04:56
"Edit" the current webpage by turning on edit mode - only temporary of course
javascript:document.body.contentEditable = 'true'; document.designMode='on'; void 0
@oaustegard
oaustegard / qubole_csv.js
Created April 9, 2020 05:11
One-click download of Qubole query result as a CSV with headers
javascript:try{$(".query-result-download-csv")[0].click()}catch{alert('Must be clicked from Qubole Workbench Command')}
@oaustegard
oaustegard / google_keywords.js
Created April 9, 2020 05:30
Search Google for Gannett article keywords
//content-keywords only - OR
javascript:try{window.open("https://www.google.com/search?hl=en&gl=us&tbm=nws&authuser=0&q="+gciData[0]["content-keywords"].split(",").join(" OR "))}catch{alert("Must be Gannett article")}
//content keywords or title
javascript:try{window.open("https://www.google.com/search?hl=en&gl=us&tbm=nws&authuser=0&q="+gciData[0]["content-title"]+" OR "+gciData[0]["content-keywords"].split(",").join(" OR "))}catch{alert("Must be Gannett article")}