Skip to content

Instantly share code, notes, and snippets.

@jlewin
jlewin / filterScholarResults.js
Last active December 12, 2015 08:49
Filter Scholar Citation Results
var apa;
var results = document.querySelectorAll('.gs_citf');
for(var i = 0; i < results.length; i++) {
if(results[i].textContent == 'APA')
apa = results[i];
}
console.log(apa.nextSibling.querySelector('div').textContent);
@jlewin
jlewin / overrideScholarCiteLink.js
Last active December 12, 2015 08:49
Fiddle with Scholar - Override the default behavior of the 'Cite' link and instead search for the APA reference and write the results to the console
@jlewin
jlewin / countTabs.js
Last active March 7, 2023 17:21
Count of open tabs in Chrome
chrome.windows.getAll({populate: true}, function(allWindows)
{
console.log(allWindows);
});
@jlewin
jlewin / filterForChargers.js
Created April 13, 2013 18:52
Filter RCGroups.com forum results for a given term, using jQuerify
$('#threadslist tr').each(function(x){
if($(this).text().toLowerCase().indexOf('charger') == -1) {
$(this).hide();
}
}); '' // Do not output results;
@jlewin
jlewin / altPageImages.js
Created May 5, 2013 18:31
Fallback for cases where no OpenGraph or RichSnippet image exist and websnap fails. Modeled after the behavior exhibited by Google+
var images = document.querySelectorAll('img');
for(var x in images) {
var w = parseInt(images[x].getAttribute('width'));
if(w > 100)
console.log(images[x].src);
}
function extractContentUrlFromFlashVars(){
var segments = $('#scPlayer param[name=flashVars]').attr('value').split('&'),
flashVars = {},
segment,
index;
for (var i = 0; i < segments.length; i++)
{
segment = segments[i];
index = segment.indexOf('=');
@jlewin
jlewin / collectPlaylistsFromRhapsody.js
Created May 13, 2013 17:01
Adaption of my dumpToDiskViaFileSystemAPI.js Gist to free playlist data from Rhapsody
// Define the success callback for webkitRequestFileSystem()
function onInitFs(fs) {
// Grab each playlist element from the Rhapsody Playlists view, collect data for the playlist
// then invoke the 'Add to Mixer' url to collect the playlist JSON
$('#content-frame li').each(function () {
// Markup template:
// <li class="playlist playlist-item" href="/members/071tm1/playlists/mp.154595841" playlist_id="mp.154595841" playlist_name="2007-05">
var $this = $(this),
@jlewin
jlewin / collectLibraryFromRhapsody.js
Created May 14, 2013 00:02
Adaption of my dumpToDiskViaFileSystemAPI.js Gist to free Library data from Rhapsody
var context;
// Define the success callback for webkitRequestFileSystem()
function onInitFs(fs) {
// Collect list of artists from the Rhapsody Library view. For each artist, we will request the
// library details and find the albums and tracks from each. This requires an xhr foreach
// and to easy the load and appear less bot like, perform requests in sequence at
// random intervals
context = {
@jlewin
jlewin / ListDuplicateFiles.cs
Created June 27, 2013 18:23
List duplicate files in a directory
/// <summary>
/// Processes a given directory, grouping and listing files with duplicate content
/// </summary>
/// <param name="directory">The path to process</param>
private void ListDuplicateFiles(string directory)
{
// Calculate and store the hash and path for each file in the directory
var files = Directory.GetFiles(directory).Select(f => new { Path = f, Hash = FileHash.CalculateFromFile(f) });
// Group and iterate when duplicates exist
@jlewin
jlewin / VolumeControl.java
Last active December 19, 2015 01:59
Very rough prototype for remote volume management on Android
package com.hifov.remotevolumecontrol;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.text.DateFormat;