Skip to content

Instantly share code, notes, and snippets.

View jrutter's full-sized avatar

Jake Rutter jrutter

View GitHub Profile
@eric1234
eric1234 / image-defer.js
Last active July 10, 2017 15:17
Deferred image loading
var ImageDefer = Class.create({
initialize: function(placeholder) {
this.placeholder = $(placeholder);
this.placeholder.update('Loading image...');
if(ImageDefer.page_loaded) {
this.preload();
} else {
Event.observe(window, 'load', (function() {this.preload()}).bind(this));
}
@dawsontoth
dawsontoth / Geolocation.js
Created February 9, 2011 23:35
Constantly Updating Geolocation in Appcelerator Titanium
Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
Titanium.Geolocation.distanceFilter = 0;
var win = Ti.UI.createWindow({backgroundColor: '#fff'});
var label = Ti.UI.createLabel();
win.add(label);
win.open();
function reportPosition(e) {
if (!e.success || e.error) {
@thefuxia
thefuxia / t5-comment-textarea-on-top.php
Last active October 4, 2015 01:27
Makes the textarea the first field of the comment form.
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Comment Textarea On Top
* Plugin URI: http://toscho.de/?p=2239
* Description: Makes the textarea the first field of the comment form.
* Version: 2012.09.04
* Author: Thomas Scholz <info@toscho.de>
* Author URI: http://toscho.de
* License: MIT
* License URI: http://www.opensource.org/licenses/mit-license.php
@mshafrir
mshafrir / states_hash.json
Created May 9, 2012 17:05
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@aaronksaunders
aaronksaunders / app.js
Created May 20, 2012 21:28
Appcelerator Titanium Yelp API v2.0 Integration
//
// Aaron K. Saunders
//
// http://www.clearlyinnovative.com
// http://blog.clearlyinnovative.com
// @aaronksaunders
//
// SEE http://bytespider.github.com/jsOAuth/ for jsOAuth.js
//
Ti.include("jsOAuth.js");
@tomoyukiinoue
tomoyukiinoue / 00_prepare
Created October 14, 2012 04:08
Install Rails 3.2.8 for Mac OS X Mountain Lion (10.8.2)
1. Install Xcode 4.5.1 from AppStore.
1. Install Command Line Tools via Xcode preferences.
@DiegoSalazar
DiegoSalazar / validate_credit_card.js
Last active February 12, 2024 05:09
Luhn algorithm in Javascript. Check valid credit card numbers
// Takes a credit card string value and returns true on valid number
function valid_credit_card(value) {
// Accept only digits, dashes or spaces
if (/[^0-9-\s]+/.test(value)) return false;
// The Luhn Algorithm. It's so pretty.
let nCheck = 0, bEven = false;
value = value.replace(/\D/g, "");
for (var n = value.length - 1; n >= 0; n--) {
@steinbring
steinbring / StoreFormValuesInLocalStorage-Part1.html
Created November 18, 2012 01:35
How to use localStorage and sessionStorage to make form values persistant
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="windows-1252">
<title>Keep webform data persistent</title>
<!-- jQuery CDN -->
<script src="http://code.jquery.com/jquery-latest.js"></script>
<style type="text/css">
/*Float the form labels to the left and allow them 40% of the width of the form*/
@afeld
afeld / gist:4952991
Last active February 8, 2022 03:13
good APIs for mashups

This list has been superseded by Public APIs. Check there for APIs with Auth: No, HTTPS and CORS Yes.


List of data APIs that require no server-side auth or private credentials, and are thus good for small browser-only JS projects.

@chrislkeller
chrislkeller / import_json_appsscript.js
Last active March 25, 2024 19:45
Adds what amounts to an =ImportJSON() function to a Google spreadsheet... To use go to Tools --> Script Editor and add the script and save.
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();