Skip to content

Instantly share code, notes, and snippets.

View rocktronica's full-sized avatar
😎
sup

Tommy rocktronica

😎
sup
View GitHub Profile
@rocktronica
rocktronica / refresh.js
Created July 9, 2012 15:07
refresh page w/ iframe
(function(win, doc, body){
var iCounter = 0, sUrl = doc.location.href, sTitle = doc.title || sUrl,
iMinutes = parseFloat(prompt("Seconds till refresh", "60"),10) || 60;
doc.head.innerHTML = body.innerHTML = '';
body.style.overflow = 'hidden';
var iframe = win.iframe = doc.createElement("iframe");
iframe.src = doc.location.href;
@rocktronica
rocktronica / nextup.js
Created June 11, 2012 03:04
nextUp(); getting next higher permutation of number
// Given a number, find the next higher number which has the exact same set of digits as the original number
// http://stackoverflow.com/questions/9368205/given-a-number-find-the-next-higher-number-which-has-the-exact-same-set-of-digi
function nextUp(iNumber){
var sDigitsSorted = iNumber.toString().split('').sort().join('');
var aPermutations = (function(){
var i = parseInt(iNumber.toString().split('').sort().reverse().join(''),10) + 1,
a = [];
@rocktronica
rocktronica / urlparamcleanup.html
Created May 10, 2012 02:30
URL Param Cleanup
data:text/html, <pre id="pre"></pre> <script> document.getElementById("pre").innerHTML = JSON.stringify( (function(s){ var s = (!!s.match(/\?/)) ? s.substr(s.indexOf("?")+1) : s; var qs = s.split("+").join(" "), params = {}, tokens, re = /[?&]?([^=]+)=([^&]*)/g; while (tokens = re.exec(qs)) { params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]); } return params; } (prompt("?=?"))), null, 4 ); </script>
@rocktronica
rocktronica / wordfrequency.js
Created May 7, 2012 01:58
quick and dirty word frequency analysis
var words = (function(){
var sWords = document.body.innerText.toLowerCase().trim().replace(/[,;.]/g,'').split(/[\s\/]+/g).sort();
var iWordsCount = sWords.length; // count w/ duplicates
// array of words to ignore
var ignore = ['and','the','to','a','of','for','as','i','with','it','is','on','that','this','can','in','be','has','if'];
ignore = (function(){
var o = {}; // object prop checking > in array checking
var iCount = ignore.length;
@rocktronica
rocktronica / newdate.js
Created May 4, 2012 23:51
location.search="?"+(+new Date());
javascript:(function(){location.search="?"+(+new Date());}())
data:text/html,Loading...<script>document.body.innerHTML=prompt("html?")</script>
@rocktronica
rocktronica / sure.js
Created May 4, 2012 23:47
bookmarklet to confirm leave
javascript:(function(){window.onbeforeunload=function(){return '';}})();
@rocktronica
rocktronica / gist:2367523
Created April 12, 2012 14:04
trying to fix false absolute URLs when using IP address as localhost
(function () {
// only run on IPs and browserling tunnel
if ((!!parseInt(location.host.replace(/\./g, ''), 10)) || (!!location.href.match('browserling'))) {
// fake out DOM to get URL ports
function getPort(sUrl) {
var a = document.createElement("a");
a.href = sUrl;
return a.port;
@rocktronica
rocktronica / hncommentsearch.js
Created April 1, 2012 17:51
Search and highlight HackerNews comments
// Paste this into your JS console, love.
var sNeedle = prompt("Find what?").toLowerCase();
var tds = document.getElementsByClassName("default");
var iTdCount = tds.length;
for (var i = 0; i < iTdCount; i++) {
var td = tds[i];
var sHtml = td.innerHTML.toLowerCase();
if (sHtml.indexOf(sNeedle) > -1) {
@rocktronica
rocktronica / bubblejax.php
Created March 27, 2012 20:33
bubblejax.php before stripping wpdb stuff
<?php
/*
Plugin Name: BubbleJax Wrapper
Plugin URI: http://bubblelifemedia.com/
Description: Name pending.
Author: Tommy
Version: 0.1
Author URI: http://bubblelifemedia.com/
*/