Skip to content

Instantly share code, notes, and snippets.

@ktaragorn
ktaragorn / cdc_add_to_google_calendar.user.js
Created April 4, 2018 14:40
Add CDC (ComfortDelgro Driving Centre) class bookings to google calendar
// ==UserScript==
// @name Add CDC (ComfortDelgro Driving Centre) class bookings to google calendar
// @namespace ktaragorn
// @description Adds a link to export the class booking to google calendar so that you dont make mistakes in manual entry of date/time and miss the class
// @include https://www.cdc.com.sg/NewPortal/Booking/ReportPrView.aspx?ReceiptNo=*
// @version 2
// @grant none
// ==/UserScript==
function make_date(time_array){
@ktaragorn
ktaragorn / youtube_watchlater.user.js
Last active August 30, 2017 03:16
Copy Video Links from Youtube Watch Later
// ==UserScript==
// @name Copy Video Links from Youtube Watch Later
// @namespace ktaragorn
// @description Copy Video Links from Youtube Watch Later for later downloading
// @include https://www.youtube.com/playlist?list=WL
// @version 2
// @grant none
// ==/UserScript==
function getUrls(){
@ktaragorn
ktaragorn / yourturnmyturn_notification.user.js
Last active July 5, 2017 06:34
Desktop Notifications for YourTurnMyTurn
// ==UserScript==
// @name Desktop Notifications for YourTurnMyTurn
// @namespace ktaragorn
// @include https://www.yourturnmyturn.com/status.php
// @description Desktop Notifications for YourTurnMyTurn.com overview page when it is your turn
// @version 6
// @grant none
// ==/UserScript==
function refresh()
@ktaragorn
ktaragorn / gist:a0ff7153a8eab6521fa49ac8276c9083
Last active August 30, 2017 03:19
Get all video urls in your youtube playlist (watch later list in this case). Run this in browser inspect on that page.
JSON.stringify(Array.prototype.slice.call(document.querySelectorAll(".pl-video-title-link")).map(function(a){return a.href.replace(/&list=.*/g,'').replace(/&index=.*/g,'')}))
@ktaragorn
ktaragorn / release_issues.rb
Last active March 21, 2017 09:13
Which issues have commits in the specified release branch
#!/usr/bin/env ruby
unless ARGV.first
fail("Provide the name of the release branch. For e.g for release/5.0 provide 5.0 as the branch name")
end
base = ARGV[1] || "master"
puts "Ensure that this is run in the repository you want the data from!"
`git fetch`
pr_regexp = "Merge pull request"
@ktaragorn
ktaragorn / gist:3a138330a29592ab9582dca30dddd604
Created December 16, 2016 13:46
Simple CLI to run scan or clean on kodi video library
if [ "$1" == "clean" ]
then
operation="Clean"
elif [ "$1" == "scan" ]
then
var data = $("tbody tr").map(function(){
var $row = $(this)
var category = $row.find(".record-category").text()
var date = $row.find("td:last-child .ng-binding").text().split(" ").join("").split("\n").join("")
var amount = $row.find(".nonreferential-amount span:last-child").text()
var currency = $row.find(".nonreferential-amount .currency-code").text()
var amount_sgd = $row.find(".negative-amount .record-amount").text()
var payment_type = $row.find("img.payment-icon").attr("title")
var description = $row.find(".record-note").text()
return [[category, description, amount, currency, amount_sgd, payment_type, date]]
@ktaragorn
ktaragorn / ssh_config
Created July 5, 2016 03:49
Complicated ssh config with wildcards and DRY settings for many machines. http://stackoverflow.com/questions/38194800/ssh-config-file-setup-with-wildcards-and-dry
Host shortname1?
Hostname %h.prod.xyz.com
Host test-myname
Hostname combo.test-myname.xyz.com
Host *.xyz.com
Hostname %h
Match Host *.xyz.com
@ktaragorn
ktaragorn / table.rb
Last active January 17, 2017 03:54
Simple script that lets you add table view to any irb - just copy paste and use with `table <list of arrays or hashable objects>`. `htable` works the same as `table`, but generates a horizontal table.
def get_columns list, options = {}
all = list.map{|item| item.columns}.flatten.uniq
symize = ->(key){key.try(:to_sym) || key}
if options[:only]
Array(options[:only]).map(&symize) & all
elsif options[:keys_search]
all.select{|k| k.to_s.downcase.match(options[:keys_search].to_s.downcase)}
else
all - Array(options[:not]).map(&symize)
@ktaragorn
ktaragorn / progress_bar.rb
Last active March 31, 2016 08:12
A simple progress bar class
class ProgressBar
def initialize max
@max = max
@current = 0.0
end
def draw
progress = @current/@max
wipe = "\r"
bar_length = 20