Skip to content

Instantly share code, notes, and snippets.

View padolsey's full-sized avatar

James Padolsey padolsey

View GitHub Profile
(function(_init){
jQuery.fn.init = function(selector, context){
var jQueryObj = new _init(selector, context);
jQueryObj.valueOf = function(){
return this.length;
};
return jQueryObj;
};
<script src="http://widgets.twimg.com/j/1/widget.js">
new TWTR.Widget({
search: 'my search query',
id: 'twtr-search-widget',
loop: true,
title: 'what people say about...',
subject: 'stuff and things',
width: 250,
height: 300,
theme: {
(function(){
var special = jQuery.event.special,
uid1 = 'D' + (+new Date()),
uid2 = 'D' + (+new Date() + 1);
jQuery.event.special.focus = {
setup: function() {
var _self = this,
handler = function(e) {
/* Place this at the very top of Sizzle() */
var rContextID = /^\s*#(\S+)(?=\s+\S)/;
// Looking for "#id _somethingElseHere_" ...
if (!context && rContextID.test(selector)) {
context = document.getElementById( rContextID.exec(selector)[1] );
selector = selector.replace(rContextID, '');
}
// Usage:
// Target all links with an ID starting with "notice"
delegateEvent({nodeName:/^a$/i, id: /^notice/}, 'click', function(){
alert(this.id);
});
function delegateEvent(props, type, handler) {
var fn = function(e) {
jQuery.fn.equalHeights = function() {
return this.height(Math.max.apply(null,
this.map(function() {
return jQuery(this).height()
}).get()
));
};
var getDaysInMonth = function(m, y){
return /8|3|5|10/.test(m)?30:m==1?(!(y%4)&&y%100)||!(y%400)?29:28:31;
};
/* Make getters return full set if first arg === true */
$.each(
[
'html', 'val', 'text', 'width', 'height', 'scrollTop',
'scrollLeft', 'hasClass', 'css', 'attr', 'offset',
'position', 'outerHeight', 'outerWidth'
],
function(){
var _method = $.fn[this];
<html>
<head>
<!-- jQuery -->
<script src="path/to/jquery.js"></script>
<!-- jQuery mod (from StackOverflow) -->
<script>
... put it here ... (or load it from another file, with src="...")
</script>
public void insert(String newWord) {
dictionary.add(newWord);
Collections.sort(dictionary, new Comparator<String>(){
public int compare(String s1, String s2) {
return s1.compareToIgnoreCase(s2);
}
});
dictReader.save(dictionary);