Skip to content

Instantly share code, notes, and snippets.

View akshar100's full-sized avatar

Akshar Prabhu Desai akshar100

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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.