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
@oaustegard
oaustegard / video_pip_bookmarklet.js
Created April 10, 2020 16:12
Simple bookmarklet for Picture-in-Picture video play in Chrome
javascript:try{document.querySelector('video').requestPictureInPicture()}catch(e){alert("sorry:\n"+e)}
@oaustegard
oaustegard / getting-started-with-bigquery-and-facets.ipynb
Last active April 16, 2020 13:12
Getting started with BigQuery and Facets
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@oaustegard
oaustegard / FacetsDiveResult.js
Created April 21, 2020 05:44
Unsuccessful attempt at displaying BigQuery resultset as a Facets Dive component
(function(j,w,d){
try {
j = '';
//this works just fine to collect the json (assuming the JSON result tab is open in BigQuery)
for (e of document.getElementsByClassName("CodeMirror-code")[1].getElementsByClassName("CodeMirror-line")) {
j+= (e.innerText.trim());
}
w = window.open('about:blank','','width=900,height=700,resizeable,scrollbars');
d = w.document;
//this fails with ContentSecurity errors - see console of opened window for details
toggle_wifi() {
networksetup -getairportpower en${n};
if test $? -eq 0;
then
echo WiFi interface found: en${n};
eval "networksetup -setairportpower en${n} off"
eval "networksetup -setairportpower en${n} on"
return 0;
fi
return 1;
@oaustegard
oaustegard / private.xml
Last active May 26, 2020 18:28 — forked from rootscript/private.xml
Karabiner private.xml for non-Apple keyboard to toggle Target Display Mode
<?xml version="1.0"?>
<root>
<devicevendordef>
<vendorname>Dell</vendorname>
<vendorid>16700</vendorid>
</devicevendordef>
<deviceproductdef>
<productname>Dell USB Keyboard</productname>
<productid>8195</productid>
@oaustegard
oaustegard / getNthWeekdayOfMonth.sql
Last active May 29, 2020 12:51
BigQuery Utility Functions
-- Generates an array of dates matching the Nth (1st - 5th) weekday (Sun, Mon, Tue, etc) of each month
-- from startDate to endDate
CREATE OR REPLACE FUNCTION `yourProject.yourDB.getNthWeekdayOfMonth`(Nth INT64, weekday STRING, startDate DATE, endDate DATE) RETURNS ARRAY<DATE> AS (
(
select array
(
select dt from
(
select dt,
rank() over (partition by format_date("%a%b%Y", dt) order by dt) as WeekDayOfMonth,
@oaustegard
oaustegard / README.md
Last active February 1, 2021 16:43
BigQuery CustomTargeting processing utility UDFs

Google Ad Manager BigQuery Utility Functions

These are a few utility functions useful for parsing the CustomTargeting field present in your DFP (GAM) tables

@oaustegard
oaustegard / ConnectBluetooth.script
Last active May 29, 2020 22:05
Connect to Bluetooth Keyboard
on run {input, parameters}
activate application "SystemUIServer"
tell application "System Events"
tell process "SystemUIServer"
-- sourced from https://superuser.com/a/1348751
-- Working CONNECT Script. Goes through the following:
-- Clicks on Bluetooth Menu (OSX Top Menu Bar)
-- => Clicks on device Item
-- => Clicks on Connect Item
@oaustegard
oaustegard / CheckCookie.html
Last active June 4, 2020 21:39
OneTrust Bookmarklets
<a href="javascript:alert(decodeURIComponent(document.cookie.split('; ').filter(c=>c.startsWith('Optanon'))))">Check OneTrust Cookie</a>
@oaustegard
oaustegard / google_site_search_bookmarklet.js
Last active September 25, 2020 22:55
Google Site Search Bookmarklet
javascript:(function(){window.open("https://www.google.com/search?q=site:"+location.hostname.replace("www.","")+" "+window.prompt("Enter site search terms"))})()