Skip to content

Instantly share code, notes, and snippets.

View jwdeane's full-sized avatar

James Deane jwdeane

View GitHub Profile
@jwdeane
jwdeane / incrementer.js
Created March 19, 2009 13:51
incrementer
// Incrementer
$(document).ready(function() {
val = $('#episode').val();
$('#minus').click(function() {
if (val>0) {
$('#episode').attr('value', --val);
console.log(val);
} else if (val=0) {
@jwdeane
jwdeane / snippet.txt
Created July 8, 2009 18:14 — forked from anonymous/snippet.txt
YQL Cinema Query
select * from html where url ="http://uk.movies.yahoo.com/cinemas/index.html?mid=&cid=3266&sp=mov&zip=me13er" and xpath="//div[@class='cintbl']/table[@class='timetable']"
@jwdeane
jwdeane / removeWord.js
Created November 17, 2009 16:58
Remove a word with jQuery
// http://johannburkard.de/blog/programming/javascript/6-quick-jquery-tips-text-manipulation-timers-and-elements.html
// The simple way – using regular expressions:
var el = $('#id');
el.html(el.html().replace(/word/ig, ""));
@jwdeane
jwdeane / selectiveTweet.js
Created November 18, 2009 13:00
Remove #fb from tweets
// Assuming use of http://code.google.com/p/twitterjs/ for publishing to your website, and
// http://apps.facebook.com/selectivetwitter/ for publishing to Facebook
function fbRemove() {
$('#tweet li').each(function() {
var el = $(this);
el.html(el.html().replace(/\s*#.*fb<\/a>/ig, ''));
});
}
(?x)
\b
( # Capture 1: entire matched URL
(?:
[\w-]+: # URL protocol and colon
(?:
/{1,3} # 1-3 slashes
| # or
[[:alpha:][:digit:]] # Single letter or digit
# (Try not to match, say "URI::Escape")
@jwdeane
jwdeane / opacity.css
Created December 11, 2009 00:03
Cross browser opacity
selector {
opacity: .75; /* Standard: FF gt 1.5, Opera, Safari */
filter: alpha(opacity=75); /* IE lt 8 */
-ms-filter: "alpha(opacity=75)"; /* IE 8 */
-khtml-opacity: .75; /* Safari 1.x */
-moz-opacity: .75; /* FF lt 1.5, Netscape */
}
/* Source: http://snipplr.com/view/10094/crossbrowser-opacity/ */
@jwdeane
jwdeane / randomImage.js
Created January 21, 2010 10:32
display random image with jQuery
// Basic Random Image Rotator
// jQuery required http://jquery.com
// Easy option
// img is an array of images
var img = ['img1.jpg','img2.jpg','img3.jpg','img4.jpg'];
// src="images/rotator/ is path to your files contained in above array
$('<img src="images/rotator/' + images[Math.floor(Math.random() * images.length)] + '">').appendTo('#imageContainer');
////////////////////////////
@jwdeane
jwdeane / Change WP domain
Created August 9, 2010 14:20
Changed your Wordpress domain?
// Edit themes functions.php. Right after initial <?php line place the following:
update_option('siteurl','http://example.com/blog');
update_option('home','http://example.com/blog');
define (['knockout', 'jquery', 'prettyDate', 'metrojs'], function ( ko, $ ) {
"use strict";
// See https://github.com/SteveSanderson/knockout/wiki/Bindings---class
ko.bindingHandlers['class'] = {
'update' : function ( element, valueAccessor ) {
if ( element['__ko__previousClassValue__'] ) {
ko.utils.toggleDomNodeCssClass (element, element['__ko__previousClassValue__'], false);
}
var value = ko.utils.unwrapObservable (valueAccessor ());
define (['knockout', 'jquery', 'prettyDate', 'metrojs'], function ( ko, $ ) {
"use strict";
// See https://github.com/SteveSanderson/knockout/wiki/Bindings---class
ko.bindingHandlers['class'] = {
'update' : function ( element, valueAccessor ) {
if ( element['__ko__previousClassValue__'] ) {
ko.utils.toggleDomNodeCssClass (element, element['__ko__previousClassValue__'], false);
}
var value = ko.utils.unwrapObservable (valueAccessor ());