Skip to content

Instantly share code, notes, and snippets.

View akshar100's full-sized avatar

Akshar Prabhu Desai akshar100

View GitHub Profile
@akshar100
akshar100 / Graph Generation
Created October 7, 2011 12:33
Generates a Graph for my MTP stage 1
function drawVisualization() {
// Create and populate the data table.
var data = new google.visualization.DataTable();
var raw_data = [['Latency',200093,200602,201115,201686,202209,202712,203231,203741,204260,204811,205312,205830,206339,206842,207356,207857,208371,208886,209403]];
var years = [];
for(var i = 1; i <raw_data[0].length;i++)
{
years.push(i);
}
@akshar100
akshar100 / firebird_joystick.py
Created April 11, 2012 10:17
Firebird control via joystick
# Author: Akshar Prabhu Desai
# Date: 20/04/2011
# Objective: To interface FB5 with joystick
#
import pygame
import inspect
import math
import time
exec(open("functionList.py").read());
@akshar100
akshar100 / pygame_joystick.py
Created April 11, 2012 10:15
Pygame Joystick control
# Author: Akshar Prabhu Desai
# Date: 20/04/2011
# Objective: To interface FB5 with joystick
#
import pygame
import inspect
import math
import time
exec(open("functionList.py").read());
@akshar100
akshar100 / xbee_python.py
Created April 11, 2012 10:17
Xbee and Python
def init(port):
import zigbee;
zigbee.init(port);
def forward():
import zigbee;
zigbee.sendString("a");
def stop():
import zigbee;
zigbee.sendString(" ");
def backward():
@akshar100
akshar100 / genericModel
Created July 22, 2012 12:41
GenericModel
var GenericModel = Y.Base.create('GenericModel', Y.Model, [], {
sync: genericModelSync
,idAttribute:'_id'
});
var PostModel = Y.Base.create('postModel', Y.Model, [], {
sync: modelSync,
idAttribute: '_id',
profilePic: function () {
return baseURL + 'in/profile_pic/' + this.get('author_id');
},
initializer: function (config) {
@akshar100
akshar100 / gist:3786844
Created September 26, 2012 08:45
States in India Python
('Andhra Pradesh','Andhra Pradesh'),
('Arunachal Pradesh','Arunachal Pradesh'),
('Assam','Assam'),
('Bihar','Bihar'),
('Chhattisgarh','Chhattisgarh'),
('Delhi','Delhi'),
('Goa','Goa'),
('Gujarat','Gujarat'),
('Haryana','Haryana'),
('Himachal Pradesh','Himachal Pradesh'),
@akshar100
akshar100 / gist:3789842
Created September 26, 2012 18:56
Y.CommonModel
/**
* Validations Facade. All the validation rules go here.
*/
Y.ValidationFacade = Y.Base.create("ValidationFacade", Y.Base, [], {
validations: {
trim: function(key, val, attrs) {
if (!val) {
val = "";
}
@akshar100
akshar100 / gist:3913836
Created October 18, 2012 18:09
youtube matcher
/https?:\/\/(?:[a-zA_Z]{2,3}.)?(?:youtube\.com\/watch\?)((?:[\w\d\-\_\=]+&amp;(?:amp;)?)*v(?:&lt;[A-Z]+&gt;)?=([0-9a-zA-Z\-\_]+))/i
@akshar100
akshar100 / gist:5712149
Created June 5, 2013 07:17
Mojito Session Management Addon. Note: This addon is not tested. It is vulnerable to session hijacking.
YUI.add('mojito-session-addon', function(Y, NAME) {
function MojitoSession(command, adapter, ac) {
// The "command" is the Mojito internal details
// for the dispatch of the mojit instance.
// The "adapter" is the output adapter, containing
// the "done()", "error()", etc, methods.
// The "ac" is the ActionContext object to which
// this addon is about to be attached.
var sessionCookie = ac.cookie.get("sid");
if(!sessionCookie){