Skip to content

Instantly share code, notes, and snippets.

@mohamedmansour
mohamedmansour / gist:803631
Created January 31, 2011 04:11
Get and Set localStorage from Content Script
// Content Script to save data.
chrome.extension.sendRequest({storage: 'foo', value: 'bar'});
// Content Script to get data.
chrome.extension.sendRequest({storage: 'foo'}, function(response) {
console.log('foo => ' + response.storage);
});
// Background Page
@evadne
evadne / uiwebview_fullscreen_media_playback_with_autororation_workaround.m
Created February 22, 2011 14:31
UIWebView Full-Screen Movie Post-Autorotation-Dismissal Layout Fix
@implementation IRWebViewController (irFullscreenMediaPlaybackAutorotationLayoutFix)
- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
// There is a bug, where launching a media player from the web view, fullscreening it, then rotating the device, and tapping on the media to see the timelime, causes the layout to go all berserk. This is a hack to combat that.
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
if ((!self.view.superview) || (self.parentViewController.modalViewController != self) || (self.modalPresentationStyle != UIModalPresentationFullScreen)) {
@batmat
batmat / renameJpgWithDateTimeOrigalExif.groovy
Created March 17, 2011 19:23
Small Groovy script to process a pictures directory and rename them using "Date/Time original" exif field. Useful for example if you want your photos automatically sorted by their names, as if it was sorted by the photo date. My case: useful in the Ph
// Using metadata-extractor-2.4.0-beta-1.jar from http://www.drewnoakes.com/drewnoakes.com/code/exif/sampleUsage.html
import com.drew.metadata.Metadata
import com.drew.imaging.jpeg.JpegMetadataReader
import com.drew.metadata.Directory
import com.drew.metadata.Tag
import java.text.*;
def dirToProcess = new File(".")
assert dirToProcess.exists()
@Kouzuka
Kouzuka / mdfind-dired.el
Created April 3, 2011 14:33
Provides an interface to `mdfind' and a functionality to open Smart Folders in Dired.
;;; mdfind-dired.el --- run a `mdfind' command and dired the output
;; Copyright (C) 1992, 1994, 1995, 2000, 2001, 2002, 2003, 2004,
;; 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
;; Copyright (C) 2011 Kouzuka
;; Author: Roland McGrath <roland@gnu.org>,
;; Sebastian Kremer <sk@thp.uni-koeln.de>
;; Kouzuka
;; Keywords: unix
@insin
insin / index.html
Last active October 29, 2024 01:21
Export a <table> to Excel - http://bl.ocks.org/insin/1031969
<!DOCTYPE html>
<html>
<head>
<title>tableToExcel Demo</title>
<script src="tableToExcel.js"></script>
</head>
<body>
<h1>tableToExcel Demo</h1>
<p>Exporting the W3C Example Table</p>
@tmcw
tmcw / disconnect.rb
Created July 22, 2011 04:06
bulk-export run data from Garmin Connect
#!/usr/bin/env ruby
## disconnect
# ./disconnect.rb -u yourusername
#
# This is a command-line utility for the bulk-downloading of run data from
# the connect.garmin.com web application, which has lackluster export
# capabilities.
#
@cosimo
cosimo / time-response.pl
Created July 23, 2011 14:39
Simple tool to detect TCP retransmit timeouts through HTTP requests
#!/usr/bin/env perl
#
# Fires HTTP request batches at the specified hostname
# and analyzes the response times.
#
# If you have suspicious frequency of 3.00x, 9.00x, 21.00x
# seconds, then most probably you have a problem of packet loss
# in your network.
#
# cosimo@opera.com, sometime in 2011
@abombss
abombss / toggle-list-sep.ps1
Created August 6, 2011 19:18
Powershell script to toggle and change the windows regional settings for the list separator to make outputting CSV files from excel using different delimiters much easier
function toggle-list-sep
{
$path = "hkcu:\Control Panel\International"
$key = "sList"
$cur_sep = (Get-ItemProperty -path $path -name $key).$key
if ($args.Length -gt 0) { $value = $args[0] }
elseif ($cur_sep -eq ",") { $value = "|" }
else { $value = "," }
@coldnebo
coldnebo / Default (Linux).sublime-keymap
Created August 10, 2011 23:20
simple scripts to prettify your xml and json in sublime text 2
[
{ "keys": ["ctrl+shift+x"], "command": "tidy_xml" },
{ "keys": ["ctrl+shift+j"], "command": "prettify_json" }
]
@cdown
cdown / gist:1163649
Last active August 10, 2026 06:43
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in