Skip to content

Instantly share code, notes, and snippets.

@joelpt
joelpt / embed-youtube-player-in-reddit-comments.md
Last active May 8, 2020 04:40
YouTube embedded player in reddit.com comments

This script dynamically embeds YouTube players into reddit comments wherever a comment references a YouTube video URL. It is a prototype of functionality I would like to see added to RES.

In Chrome:

  • Download the Personalized Web extension
  • Create a new rule:
    • Rule name: YouTube embedded in reddit comments
    • Match URLs: ^http://.+reddit.+\/
    • In 'Add HTML', paste the contents of script.js in this gist
  • Click Save button.
@joelpt
joelpt / SidewiseTaskbarHider.ahk
Created October 29, 2012 17:06
Hide the Sidewise icon from the Windows taskbar and take it out of the alt-tab list.
;#NoTrayIcon ; uncomment this to also hide this script's systray icon
init()
return
init() {
; Configure event hook for window-created message reception
Gui +LastFound
hWnd := WinExist()
DllCall( "RegisterShellHookWindow", UInt,hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
@joelpt
joelpt / squirt.js
Created October 2, 2012 23:41
Manually calculate the square root of a number with Javascript
// The Babylonian Method
// http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method
// @param n - the number to compute the square root of
// @param g - the best guess so far (can omit from initial call)
function squirt(n, g) {
if (!g) {
// Take an initial guess at the square root
g = n / 2.0;
}
var d = n / g; // Divide our guess into the number
@joelpt
joelpt / extendClass.js
Created June 25, 2012 16:25
Javascript fancy inheritance extendClass()
///////////////////////////////////////////////////////
// extendClass(): subclassing for Javascript
///////////////////////////////////////////////////////
// extendClass won't create surrogate child functions for these function names.
var EXTEND_CLASS_BANNED_SURROGATE_NAMES =
['constructor', '$base', '$super', '$parent'];
// Inherit superClass's prototype onto subClass.
// Adds properties of prototype argument to subClass's prototype.
@joelpt
joelpt / go-to-anything.ahk
Created April 16, 2012 18:51
Go To Anything for Autohotkey - highlight some text, hit Win+G and "go"!
;; Go to anything that is in the currently selected text: URLs, email addresses, Windows paths, or just "Google it"
;; Forum topic: http://www.autohotkey.com/community/viewtopic.php?f=2&t=85152&p=537116
$#G::
;Tip("Clipping...") ;; include my mouse-tip library for this https://gist.github.com/2400547
clip := CopyToClipboard()
if (!clip) {
return
}
addr := ExtractAddress(clip)
if (!addr)
@joelpt
joelpt / site-named-email.ahk
Created April 16, 2012 18:34
Type <sitename>@mydomain.com in Google Chrome for Autohotkey
;; Chrome has been seen with any of these class names
GroupAdd, GoogleChrome, ahk_class Chrome_WindowImpl_0
GroupAdd, GoogleChrome, ahk_class Chrome_WidgetWin_0
GroupAdd, GoogleChrome, ahk_class Chrome_WidgetWin_1
;; My email domain name
EmailDomainName := "mydomain.com"
;; Send sitename@mydomain.com
#IfWinActive ahk_group GoogleChrome
@joelpt
joelpt / mouse-tip.ahk
Created April 16, 2012 18:32
Mouse pointer anchored tooltip for Autohotkey
#Persistent
; update mouse tooltip position this often, in ms
; 10 ms looks the smoothest, but you may prefer a higher value
; if the CPU load is too high with 10 ms
MouseTipUpdateInterval := 10
; a usage example
Tip("This is an example mousetip.")