Skip to content

Instantly share code, notes, and snippets.

View rodneyrehm's full-sized avatar

Rodney Rehm rodneyrehm

View GitHub Profile
@rodneyrehm
rodneyrehm / URI.fragment.js
Last active January 1, 2016 13:29
URI.js fragment overloading for seamless `!/some/path` and `?some=data` handling
/*
* Extending URI.js for fragment abuse
*/
// --------------------------------------------------------------------------------
// EXAMPLE: storing a relative URL in the fragment ("FragmentURI")
// possibly helpful when working with backbone.js or sammy.js
// inspired by https://github.com/medialize/URI.js/pull/2
// --------------------------------------------------------------------------------
@rodneyrehm
rodneyrehm / gist:8117811
Last active January 1, 2016 08:19
Sourcing.io Feedback

Hey Alex,

I just signed up for sourcing.io. I'm not looking to hire, it was to get a demo of the system. Some feedback / questions:

  • giving you my CC data for a quick demo feels weird. Can't you suspend the account after $x searches or $x days and require the CC data then?
  • I signed up to see what my personal profile looked like. The only way I could find myself was through a direct search for my name. The filters didn't really work. Maybe this can be made accessible without login?
  • You seem to have my github account, but not my twitter. Works for Sven but not me
  • You're not looking at the github repositories of organizations - DalekJS isn't showing up for Sebastian
  • I can't find Jörn Zaefferer (jQueryUI, QUnit) at all
  • What's the color coding of the projects supposed to mean? some are red, is tha
@rodneyrehm
rodneyrehm / gist:8013067
Created December 17, 2013 21:41
JavaScript - URL validation RegExp
// see http://rodneyrehm.de/t/url-regex.html#imme_emosol for the complete table
// expression by
var url_pattern = /^(https?|ftp|torrent|image|irc):\/\/(-\.)?([^\s\/?\.#-]+\.?)+(\/[^\s]*)?$/i;
var valid = [
"http://foo.com/blah_blah",
"http://foo.com/blah_blah/",
"http://foo.com/blah_blah_(wikipedia)",
"http://foo.com/blah_blah_(wikipedia)_(again)",
@rodneyrehm
rodneyrehm / gist:7302213
Last active December 27, 2015 09:09
@helloanselm: simple off-dom storage added to dom nodes
(function() {
var storage = {};
var counter = 1;
function nodeId(node) {
return node._dataId || (node._dataId = counter++ );
}
function nodeData(node, key, value) {
var id = nodeId(node);
@rodneyrehm
rodneyrehm / gist:6464641
Last active September 18, 2020 02:53
Rachel Nabors: touch and click
// https://coderwall.com/p/yzlqpq
(function($){
function touch(event) {
event.preventDefault();
var runFunc = $(this).data('activateRunFunc');
runFunc && runFunc();
}
function click(event) {
event.preventDefault();
@rodneyrehm
rodneyrehm / gist:6169060
Created August 6, 2013 21:52
debugging-games: spot-the-dot
// ruining debugging-games: spot-the-dot
$.fn.hasClass = (function(orig){
return function(className) {
if (typeof className !== 'string') {
throw new Error("jQuery.hasClass() expects a string!");
} else if (className.slice(0, 1) === '.') {
throw new Error("jQuery.hasClass() does not expect a . prefixing the className");
}
return orig.apply(this, arguments);
@rodneyrehm
rodneyrehm / keep-focus.js
Last active December 19, 2015 04:59 — forked from drublic/keep-focus.js
Maintain Focus on elements within a given element
var tabbableElements = 'a[href], area[href], input:not([disabled]),'
+ 'select:not([disabled]), textarea:not([disabled]),'
+ 'button:not([disabled]), iframe, object, embed, *[tabindex],'
+ '*[contenteditable]';
var keepFocus = function (context) {
var elements = context.querySelectorAll(tabbableElements);
var keyListener = function (event) {
var keyCode = event.which || event.keyCode;
@rodneyrehm
rodneyrehm / anti-keygrabber.user.js
Last active May 26, 2024 17:50
GreaseMonkey: Prevent Web Applications From Grabbing Certain HotKeys
// ==UserScript==
// @name anti key-grabber
// @description Prevent web apps from capturing and muting vital keyboard shortcuts
// @grant none
// @version 1.1
// ==/UserScript==
(function(){
var isMac = unsafeWindow.navigator.oscpu.toLowerCase().contains("mac os x");
unsafeWindow.document.addEventListener('keydown', function(e) {
if (e.keyCode === 116) {
@rodneyrehm
rodneyrehm / external-resource.php
Last active December 11, 2015 11:58
W3C-Test helper for remote resources on demand (CSS/JS/JSON/IMG, delayed response, http response code)
<?php
// moved to https://github.com/rodneyrehm/test-resource
@rodneyrehm
rodneyrehm / README.md
Created October 29, 2012 11:53
Javascript: removing nested functions

Avoid Nesting Of Functions

Need a clear statement why: Memory issues, declaration issue, nested functions being "registered" on every invocation of containing function, …