Skip to content

Instantly share code, notes, and snippets.

@go717franciswang
go717franciswang / texts2playlist.js
Last active December 9, 2016 02:06
Tempermonkey script that given @playlistName (name of playlist in YouTube) and @playlist (array of song names), add the first search result of each song into that playlist. Start by visiting https://www.youtube.com/results?search_query=[FIRST_SONG_NAME]
// ==UserScript==
// @name texts2playlist
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Given @playlistName (name of playlist in YouTube) and @playlist (array of song names), add the first search result of each song into that playlist.
// @author Fabricator
// @match https://www.youtube.com/results?search_query=*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @grant none
// ==/UserScript==
@go717franciswang
go717franciswang / print.js
Created December 9, 2016 00:15
Print out liked songs from Pandora's "My Profile" page
$('.first').each(
function(i,v) {
var song = $(v).text();
var artist = $(v).parent().parent().find('p a:first').text();
console.log(song+' by '+artist);
}
)
{
"columns": [
{"name": "a", "friendly_name": "A", "type": "integer"},
{"name": "b", "friendly_name": "B", "type": "string"}
],
"rows": [
{"a": 1, "b": "1"},
{"b": 2, "b": "2"}
]
}
@go717franciswang
go717franciswang / backUpSharedWithMe.gs
Created February 4, 2016 20:32
Back up files that are shared with you in Google Drive. Schedule `main()` to trigger once per day.
function getRootSharedFiles() {
var files = DriveApp.searchFiles('sharedWithMe');
var rs = [];
while (files.hasNext()) {
var file = files.next();
if (!isBackUpFile(file)) continue;
rs.push(file);
}
@go717franciswang
go717franciswang / jack.vim
Created January 23, 2016 06:17
syntax highlighting for Jack language in nand2tetris
" Vim syntax file
" Language: Jack
" (http://www.nand2tetris.org/lectures/PDF/lecture%2009%20high%20level%20language.pdf)
" Maintainer: Fabricator
" Latest Revision: 21 Jan 2016
"
if exists("b:current_syntax")
finish
endif
@go717franciswang
go717franciswang / logstash.conf
Created October 1, 2015 23:58
Logstash config example of grokking on grokked field
input {
file {
type => "nginx-access"
path => ["/var/log/nginx/access.log"]
}
}
filter {
if [type] == "nginx-access" {
grok {
match => [ "message", "%{COMBINEDAPACHELOG}" ]
// ==UserScript==
// @name Tubeplus.me no ad
// @namespace fabricator
// @include http://www.tubeplus.me/*
// @version 2
// @grant none
// ==/UserScript==
// allow pasting
console.log('Removing ads...');
document.querySelector('#right').remove();
#!/bin/bash
#----------------------------------------------------
# Derivative of
# a simple mysql database backup script by Alvin Alexander
# see http://alvinalexander.com/mysql/mysql-database-backup-dump-shell-script-crontab
# by Chief Fabricator
#----------------------------------------------------
# This work is licensed under a Creative Commons
# Attribution-ShareAlike 3.0 Unported License;
@go717franciswang
go717franciswang / greaseMonkyGmailGadgetRemoval.js
Last active August 29, 2015 14:06
GreaseMonkey: remove Gmail gadgets
// ==UserScript==
// @name Remove Gmail gadgets
// @namespace chiefFrabricator
// @include https://mail.google.com/mail/u/0/*
// @version 5
// @grant none
// @updateURL https://gist.githubusercontent.com/go717franciswang/9585565ece0b3c0d435f/raw/greaseMonkyGmailGadgetRemoval.js
// @downloadURL https://gist.githubusercontent.com/go717franciswang/9585565ece0b3c0d435f/raw/greaseMonkyGmailGadgetRemoval.js
// ==/UserScript==
#!/bin/bash
# split audio file into multiple piece using avconv
# (might work for video file too)
input_file=$1
output_file_prefix=$2
batch_duration=$3
extension="${input_file##*.}"