Skip to content

Instantly share code, notes, and snippets.

Avatar

Venkat Dinavahi venkatd

View GitHub Profile
@venkatd
venkatd / jquery.event.special.imageload.js
Created Sep 17, 2011
jQuery image loaded special event
View jquery.event.special.imageload.js
(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 Nov 3, 2011
jquery data lost for onunmatch
View index.html
<!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 Nov 3, 2011
nested onmatch not fired when .append is used
View gist:1337660
<!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 Mar 12, 2012
php date format in js (untested)
View gist:2025091
(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 Apr 19, 2012
Rectangle Class
View gist:2424729
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;
View gist:2564689
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.'),
);
View active_record_association_spec.rb
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
View git_ftp.rb
require 'net/ftp'
class FtpStorage
def initialize(host, username, password)
connect(host, username, password)
end
def connect(host, username, password)
View database.yml
# 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
View data.php
$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',
You can’t perform that action at this time.