Skip to content

Instantly share code, notes, and snippets.

View samthecodingman's full-sized avatar

Samuel Jones samthecodingman

View GitHub Profile
@samthecodingman
samthecodingman / bookmarklet-gtranslate.js
Last active October 25, 2018 10:37
Reload the current page in Google Translate (English) [Javascript Bookmarklet] [CC-BY License]
javascript:(window.location.href.indexOf("translate.google.com")>-1)?((new%20RegExp('[?&]u=([^&]*)')).exec(location.search)!=null)?window.location.assign("https://translate.google.com/translate?hl=en&sl=auto&tl=en&sandbox=1&u="+(new%20RegExp('[?&]u=([^&]*)')).exec(location.search)[1]):alert("Error:%20This%20google%20translate%20page%20does%20not%20have%20a%20url%20parameter."):window.location.assign("https://translate.google.com/translate?hl=en&sl=auto&tl=en&sandbox=1&u="+encodeURIComponent(window.location.href));
@samthecodingman
samthecodingman / bookmarklet-saepaperslibrary.js
Last active February 25, 2016 05:05
View SAE Paper in SAE Digital Library [Javascript Bookmarklet]
javascript:(window.location.href.indexOf("papers.sae.org/")>-1)?window.location.assign(window.location.href.replace("papers.sae.org/","digitallibrary.sae.org/content/")):alert("Error:%20This%20bookmark%20does%20not%20work%20when%20not%20on%20the%20papers.sae.org%20domain");
@samthecodingman
samthecodingman / AltMenuDisabler.ahk
Last active February 26, 2017 07:55
Mini-script to disable the Alt key bringing up a program's context menu. Shouldn't block standard Alt-based shortcuts. Alt-codes still work. Requires AHK (https://autohotkey.com/). Source Ref: http://stackoverflow.com/a/17464301/3068190
#NoEnv
SendMode Input
#SingleInstance Force
#Persistent
Menu, Tray, Add, Quit, Quit
Menu, Tray, Default, Quit
Menu, Tray, Tip, Alt Menu Disabler
Menu, Tray, NoStandard
Return
@samthecodingman
samthecodingman / PendingUpdate.js
Last active May 3, 2018 19:50
Atomic Write Helper for the Firebase Realtime Database
/*! Copyright (c) 2017 Samuel Jones | MIT License | github.com/samthecodingman */
/* Contains contributions by @benweier and @rhalff */
/**
* A Reference represents a specific location in the Database and can be used
* for reading or writing data to that Database location.
* @typedef fbReference
* @type {firebase.database.Reference}
*/
@samthecodingman
samthecodingman / adminWorkerApp.js
Created November 3, 2017 04:21
Initializes a limited-access Firebase admin worker.
/*! adminWorkerApp.js | Samuel Jones 2017 | MIT License | github.com/samthecodingman */
/**
* @file Initializes a limited-access Firebase admin worker and returns it.
* @author Samuel Jones (github.com/samthecodingman)
*/
// Example Database Security Rules:
// 1. User must have the isAdmin claim:
// - ".read": "auth != null && auth.token.isAdmin == true"
@samthecodingman
samthecodingman / adminTaskFunction.js
Last active November 4, 2017 06:29
Defines a helper class to create Firebase Functions that handle recurring tasks that are triggered using the Firebase Realtime Database.
/*! adminTaskFunction.js | Samuel Jones 2017 | MIT License | github.com/samthecodingman */
/**
* @file Defines a helper class to create Firebase Functions that handle recurring tasks that are triggered using the Firebase Realtime Database.
* @author Samuel Jones (github.com/samthecodingman)
*/
const functions = require('firebase-functions')
const lodashGet = require('lodash').get;
@samthecodingman
samthecodingman / userinfo-database-data.js
Last active October 25, 2018 10:34
Example Firebase Realtime Database Structure - Scoped User Info (world/public/friends-only/private) [CC0 License]
// Database data
// https://console.firebase.google.com/u/0/project/PROJECT-ID/database/data
{
"userInfo": {
"userId01": {
"public": {
"username": "someuser1",
"profilePic": "https://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8", // see http://gravatar.com/site/implement/images/
...
},
@samthecodingman
samthecodingman / bookmarklet-gcache.js
Last active April 20, 2024 09:08
Reload the current page using Google's Web Cache [Javascript Bookmarklet] [CC-BY License]
javascript:(window.location.href.indexOf("webcache.googleusercontent.com")>-1)?alert("Error:%20You%20are%20on%20the%20cached%20version."):window.location.assign("http://webcache.googleusercontent.com/search?q=cache:"+encodeURIComponent(window.location.href.replace(/(^\w+:|^)\/\//,'')));
@samthecodingman
samthecodingman / bookmarklet-aliexpress.js
Last active October 25, 2018 10:33
Copies the shortened URL for the AliExpress item on the current page [Javascript Bookmarklet] [CC-BY License]
javascript:(function(d,u){if(u.indexOf("aliexpress.com/item/")<0){alert("Error:%20You%20are%20not%20on%20the%20right%20AliExpress%20page.")}else{var e=d.createElement('textarea'),u=u.replace(/\/[\w-]+\/(\d+)\.html.*/,function(m,id){return '/-/'+id+'.html'});e.value=u;d.body.appendChild(e);e.select();d.execCommand('copy');d.body.removeChild(e);alert('"'+u+'"\nwas%20copied%20to%20the%20clipboard')}})(document,window.location.href)
/*
###############################################################################################################
### HTTPRequest. Version: 2.49 ###
###############################################################################################################
HTTPRequest. Copyright © 2011-2012 [VxE]. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that
the following conditions are met: