Skip to content

Instantly share code, notes, and snippets.

@ktaragorn
ktaragorn / config.py
Created October 26, 2015 08:08
A nice way to keep app config in yaml format and load it into a attr accessible object
import yaml
from awesome_print.awesome_print import format as frmt
class AttrDict(object):
def __init__(self, dct):
self.dict = dct
def __repr__(self):
return repr(self.dict)
def __str__(self):
@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 / puma.sh
Last active January 15, 2018 09:08 — forked from ivanxuu/puma.sh
#! /bin/sh
### BEGIN INIT INFO
# Provides: pumacontrol
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Puma web server
@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 / 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 / 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"
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 / 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 / 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