Skip to content

Instantly share code, notes, and snippets.

View kballenegger's full-sized avatar

Kenneth Ballenegger kballenegger

View GitHub Profile
@kballenegger
kballenegger / Code.gs
Created February 23, 2019 08:02
gc_distance Google Sheets Script
function _tester() {
Logger.log("New test run…")
var result = gc_distance('sfo', 'jfk');
Logger.log(result)
}
function location_of(airport) {
return data[airport.toUpperCase()];
}
@kballenegger
kballenegger / glossarize.js
Created July 23, 2015 17:08
Automatically insert tooltips on all FlyerTalk pages for airport codes and common terms.
var glossary = {
"744":" 747-400",
"(S)RB":"(Sir) Richard Branson",
"*A":"the acronym stands for the Star Alliance.",
"*G":"Star Alliance Gold - Star Alliance status extended to 1Ps and 1Ks (BD*G Diamond Club Gold)",
"*S":"Star Alliance Silver - Star Alliance status extended to 2Ps and 3Ps (BD*S Diamond Club Silver)",
"-lite":"A member that obtains a status level through promotions",
"1K":"United Mileage Plus Premier Executive 1K status. Awarded to members who fly 100,000 actual miles or 100 paid segments.",
"1P":"Premier Executive - 50,000 miles or 60 segments in a calendar year",
"2K, 3K, etc.":"A less formal term to indicate those that have received 200,000 or 300,000 EQM in a year or 200 or 300 EQS in a year.",
@kballenegger
kballenegger / ihg-english.js
Last active January 3, 2023 06:55
Force IHG to speak English
// ==UserScript==
// @name IHG English
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Force IHG site to English
// @author Kenneth Ballenegger
// @match https://www.ihg.com/hotels/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=kswizz.com
// @grant none
// ==/UserScript==
@kballenegger
kballenegger / google-flights-default-USD.js
Last active January 3, 2023 05:20
Force Google Flights to use USD
// ==UserScript==
// @name Google Flights Default USD
// @version 0.1
// @description Force Google Flights to use USD
// @author Kenneth Ballenegger
// @match https://www.google.com/flights/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=kswizz.com
// @grant none
// ==/UserScript==
@kballenegger
kballenegger / Crypto.gs
Created April 14, 2021 06:02
Crypto utilities for Google Sheets
function main() {
console.log(cryptoPrice("blockstack", "0.1"));
}
/**
* Sets a random number in P1
* @customfunction
*/
function refresh() {
@kballenegger
kballenegger / fib.c
Created May 13, 2013 04:59
Fibonacci generator in C with Y-Combinator powered memoization.
//
// Fibonacci generator in C with Y-Combinator powered memoization.
//
// Written by Kenneth Ballenegger in 2013
//
#include <stdlib.h>
#include <stdio.h>
#include <Block.h>
@kballenegger
kballenegger / spotify-star-adder.rb
Created July 14, 2018 01:29
A script to add the currently playing track to a predefined playlist
#!/usr/bin/env ruby
require 'rubygems'
require 'rspotify'
require 'open3'
require 'uri'
require 'json'
# To use script
# 1/ Create an app at: https://developer.spotify.com/dashboard/applications
@kballenegger
kballenegger / hn.css
Created February 24, 2013 03:50
Custom Hacker News stylesheet. Edited from something I found on the web.
.comment p, .comment + p {
line-height: 16px;
}
.comment u, .comment u a, .comment u a:visited, .comment + p u, .comment + p u a, .comment + p u a:visited {
color: #777;
text-decoration: none ;
}
.pagetop {
@kballenegger
kballenegger / shortest-string-path-substitutions.rb
Created July 8, 2017 02:00
Shortest path between strings only substitutions
Words = Set.new
File.open('/usr/share/dict/words') do |file|
file.each do |line|
Words.add(line.strip)
end
end
Alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('')
def path(input, output)
(React.renderComponent
(dom div {:id "one" :class "two"}
(dom span {:style {:color :red, :font-weight :bold}} "HELLO ")
(dom span {:style {:color :blue}} "WORLD ")
"ola"
)
(document.getElementById "app"))