Skip to content

Instantly share code, notes, and snippets.

View akshar100's full-sized avatar

Akshar Prabhu Desai akshar100

View GitHub Profile
@akshar100
akshar100 / ViewConfigurator.js
Created November 16, 2013 20:19
View Configurator is the most complex part.
var ResponseObject = ViewConfigurator(Router.getConfig(req.getPath())) // home.index
// Normal HTTP request
if(isNormal()){
var layout = getLayoutHandlebarTemplate(ResponseObject.layout)
var output = Handlebars.compile(layout,{
"title":ResponseObject["title"].render()
//and so on. In reality we simly iterate over ResponseObject to render each component.
@akshar100
akshar100 / controller.js
Created November 16, 2013 12:02
Simple Controller
var Home = App.Controller({
"layout":"home",
"theme":"ocean"
});
Home.index = {
"title":App.Components.TitleBar,
"footer": App.Components.Footer
"welcome": App.Components.Welcome
}
@akshar100
akshar100 / ProcessLogs
Created August 30, 2013 22:32
Read all the files in the given directory. line by line and print the keyword and related text.
package com.infoaxe.logprocessor;
import java.awt.List;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import com.amazonaws.util.json.JSONException;
@akshar100
akshar100 / mojits.1.js
Created July 26, 2013 09:37
Dynamically defning Mojits.
var adapter = {
flush : function(data, meta) {
},
done : function(data1, meta) {
counter++;
queue.push(data1);
Y.mojito.util.metaMerge(parentMeta, meta);
//For Binders to work!
@akshar100
akshar100 / controller.server.js
Created June 12, 2013 08:19
Using mojito-session-addon example
/*jslint anon:true, sloppy:true, nomen:true*/
YUI.add('home', function(Y, NAME) {
/**
* The home module.
*
* @module home
*/
/**
@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){
@akshar100
akshar100 / gist:3913836
Created October 18, 2012 18:09
youtube matcher
/https?:\/\/(?:[a-zA_Z]{2,3}.)?(?:youtube\.com\/watch\?)((?:[\w\d\-\_\=]+&(?:amp;)?)*v(?:<[A-Z]+>)?=([0-9a-zA-Z\-\_]+))/i
@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: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 / genericModel
Created July 22, 2012 12:41
GenericModel
var GenericModel = Y.Base.create('GenericModel', Y.Model, [], {
sync: genericModelSync
,idAttribute:'_id'
});