Tag Archive for application

OAF – Controller Code to create Javascript popup window

String pubOrderId = pageContext.getParameter("orderId");
StringBuffer l_buffer = new StringBuffer();
StringBuffer l_buffer1 = new StringBuffer();
l_buffer.append("javascript:mywin = openWindow(top, '");
l_buffer1.append("/jct/oracle/apps/xxpwc/entry/webui/AddAttachmentPG");
l_buffer1.append("&retainAM=Y");
l_buffer1.append("&pubOrderId="+pubOrderId);
String url = "/OA_HTML/OA.jsp?page="+l_buffer1.toString();
OAUrl popupUrl = new OAUrl(url, OAWebBeanConstants.ADD_BREAD_CRUMB_SAVE );
String strUrl = popupUrl.createURL(pageContext);
l_buffer.append(strUrl.toString());
l_buffer.append("', 'lovWindow', {width:750, height:550},false,'dialog',null);");
pageContext.putJavaScriptFunction("SomeName",l_buffer.toString());

source

New Python App Shell

#!/usr/bin/env python
"""
appname v1.0.1 Copyright(c) 2008; Me, Inc.

Description of the program

usage:  appname [-g config ]
-g			config file (default is /usr/local/etc/mcp.conf)
"""

import os, sys, time, string, traceback

def _banner():
"""
Displays a banner announcing what this program is and what it does.
"""

import string

doc = string.split( __doc__, '
' )
s = doc[1] + '
' + doc[3]
n = 4
while doc[n][:6] != 'usage:':
s = s + '
' + doc[n]
n = n + 1

return s + '
'

def _usage():
"""
Displays the command line arguments for this application.
"""

import string

print _banner()

doc = string.split( __doc__, '
' )
n = 0
while ( doc[n][:6] != 'usage:' ):
n = n + 1

s = doc[n]
n = n + 1
while ( len(doc[n]) ):
s = s + '
' + doc[n]
n = n + 1

return s + '
'

def _processOpts():

# Process command line options
import getopt, sys
try:
# If the option takes a parameter, don't forget to add
# a colon immediately after the parameter.
opts, args = getopt.getopt( sys.argv[1:], "g:", "" )
except:
print _usage()
sys.exit( 1 )

config = 'config.file'

for o, a in opts:

if o == "-g":
config = a
else:
# we don't know this command line option
print _usage()
sys.exit( 1 )

return config

# If this module is being run as the main module
if __name__ == "__main__":

# Get our command line options
config = _processOpts()

source

Relaunch an application

// gcc -Wall -arch i386 -arch ppc -mmacosx-version-min=10.4 -Os -framework AppKit -o relaunch relaunch.m

#import <AppKit/AppKit.h>

@interface TerminationListener : NSObject
{
const char *executablePath;
pid_t parentProcessId;
}

- (void) relaunch;

@end

@implementation TerminationListener

- (id) initWithExecutablePath:(const char *)execPath parentProcessId:(pid_t)ppid
{
self = [super init];
if (self != nil) {
executablePath = execPath;
parentProcessId = ppid;

// This adds the input source required by the run loop
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(applicationDidTerminate:) name:NSWorkspaceDidTerminateApplicationNotification object:nil];
if (getppid() == 1) {
// ppid is launchd (1) => parent terminated already
[self relaunch];
}
}
return self;
}

- (void) applicationDidTerminate:(NSNotification *)notification
{
if (parentProcessId == [[[notification userInfo] valueForKey:@"NSApplicationProcessIdentifier"] intValue]) {
// parent just terminated
[self relaunch];
}
}

- (void) relaunch
{
[[NSWorkspace sharedWorkspace] launchApplication:[NSString stringWithUTF8String:executablePath]];
exit(0);
}

@end

int main (int argc, const char * argv[])
{
if (argc != 3) return EXIT_FAILURE;

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

[[[TerminationListener alloc] initWithExecutablePath:argv[1] parentProcessId:atoi(argv[2])] autorelease];
[[NSApplication sharedApplication] run];

[pool release];

return EXIT_SUCCESS;
}

source

My initialize cart

# Initialize shopping cart.
def initialize_cart
# #1
# --
# if session[:cart_id]
#  @cart = Cart.find(session[:cart_id])
# else
#  @cart = Cart.create
#  session[:cart_id] = @cart.id
# end

# #2
# --
# if session[:cart]
#  @cart = session[:cart]
# else
#  @cart = Cart.create
#  session[:cart] = @cart
# end

# #3
@cart = session[:cart] ||= Cart.create
end

source

Current user

protected
def current_engineer
Engineer.find(session[:user])
end

def current_user
Employee.find(session[:user])
end

def check_user_authentication
unless session[:user]
redirect_to :controller => 'account', :action => 'login'
end
end

source

Add RubyOnRails application to svn repository

svn add . --force
svn ci -m "initial rails import"
svn up
svn remove log/*
svn commit -m "removing all log files from subversion"
svn propset svn:ignore "*.*" log/
svn update log/
svn ci -m "Ignoring all files in /log/ ending in .log"
svn up
svn add config/lighttpd.conf
svn ci -m "added lighttpd conf file"
svn up
svn move config/database.yml config/database.example
svn commit -m "Moving database.yml to database.example to provide a template for anyone who checks out the code"
svn propset svn:ignore "database.yml" config/
svn update config/
svn commit -m "Ignoring database.yml"
svn remove tmp/*
svn propset svn:ignore "*" tmp/
svn update tmp/
svn commit -m "ignore tmp/ content from now"

source

Create a new svn Repository for new RoR application

mkdir ~/src/appName
svnadmin create ~/src/appName
cd ~/
mkdir ~/tmp
mkdir ~/tmp/branches
mkdir ~/tmp/tags
mkdir ~/tmp/trunk
svn import ~/tmp <a href="file:///Users/spider/src/appName" >file:///Users/spider/src/appName</a> -m "initial import"
rm -r ~/tmp
cd ~/Documents/RubyOnRails
svn checkout <a href="file:///Users/spider/src/appName/trunk" >file:///Users/spider/src/appName/trunk</a> appName

source