Skip to content

Instantly share code, notes, and snippets.

View venkatd's full-sized avatar

Venkat Dinavahi venkatd

View GitHub Profile
@venkatd
venkatd / jquery.event.special.imageload.js
Created September 17, 2011 19:51
jQuery image loaded special event
(function ($) {
function img_has_loaded(imgEl) {
var dfd = $.Deferred();
var img = new Image();
img.onload = function() {
if (!dfd.isResolved())
dfd.resolve();
}
@venkatd
venkatd / index.html
Created November 3, 2011 17:28
jquery data lost for onunmatch
<!DOCTYPE HTML>
<html>
<head>
<title>
</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.entwine.js"></script>
<script type="text/javascript">
@venkatd
venkatd / gist:1337660
Created November 3, 2011 20:15
nested onmatch not fired when .append is used
<!DOCTYPE HTML>
<html>
<head>
<title>
</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.entwine-dist.js"></script>
<script type="text/javascript">
@venkatd
venkatd / gist:2025091
Created March 12, 2012 22:27
php date format in js (untested)
(function() {
var compose = function(value, callbacks) {
if (typeof callbacks == 'function')
callbacks = [callbacks];
for (var i = 0; i < callbacks.length; i++)
value = callbacks[i](value);
return value;
@venkatd
venkatd / gist:2424729
Created April 19, 2012 22:52
Rectangle Class
function Rectangle(left, top, width, height) {
this.left = left;
this.top = top;
this.width = width;
this.height = height;
this._computeCorners();
}
Rectangle.prototype._computeCorners = function() {
this.bottom = this.top + this.height;
function mobile_redirect_form() {
$form = array();
$form['mobile_redirect_path'] = array(
'#type' => 'textfield',
'#title' => t('Path to mobile friendly page'),
'#size' => 80,
'#maxlength' => 255,
'#default_value' => variable_get('mobile_redirect_path', ''),
'#description' => t('The path to redirect to if the user is on a mobile browser.'),
);
require 'spec_helper'
describe "ActiveRecord" do
describe "association" do
it "should point to the same object" do
user = create(:user)
user.current_location.should == nil
user.update_location(latitude: 11, longitude: 22)
user.current_location.should_not == nil
require 'net/ftp'
class FtpStorage
def initialize(host, username, password)
connect(host, username, password)
end
def connect(host, username, password)
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
$data = array(
'name' => 'Dan B.',
'age' => 24,
'picture' => image('dan.png'),
'networks' => 'NYU',
'hometown' => 'Fresh Meadows, NY',
'current_city' => 'New York',
'college' => 'Cornell',
'interested_in' => 'women',
'relationship_status' => 'in a relationship',