Lots of code
Greetings,
I am a java developer, I have been so for the past 9 years. Whenever I have time on my hands, I develop applications just for fun. I have a lot of code written and would like to share all of it. Which place is the best to post all this code and application? It would be great, if a particular piece of code can be tagged with labels. For example, I developed this puzzle game... I would like to tag it with labels like "Swing, Images Manipulation" and so on and so forth. The tags essentially will make it easier for other developers to fetch code according to tags and look up stuff.
Thank you for any help.
Please excuse, If this is the wrong forum.
rksharma wrote:
I have a lot of code written and would like to share all of it. Which place is the best to post all this code and application?There's an area of this site known as SDN Share. I'm sure you'll be able to find it.
db
Similar Messages
-
i have 5 html pages that share a common header, footer, and sidebar. how do i use my nav bar to change the content of the body without duplicating a lot of code? thank you!
i inherited the website. It’s for a non-profit and is not very
sophisticated, and neither am I in webdesign. It currently has multiple
pages that are identical except for that body section, so whenever i change
the navigation (in the sidebar) I have to update every html page. I want
to have one basic page, and just call in the different body content based
on the link the user selects from the nav bar. How can i do that using a
script? i am using Dreamweaver.
~ in love and light ~
Jeannie
On Sat, Feb 7, 2015 at 4:07 AM, Ben Pleysier <[email protected]> -
Inspection lot quantity in manual inspection lot (T.Code-QA01)
Dear Experts,
I have activated inspection setup "89" with lot origin '89".I have activated this inspection set up to a material in QM view.
When i want to create a manual inspection lot through T.Code QA01, the inspection lot quantity is a required field. But i do not want to enter a quantity here. I want to create manual inspection lot without quantity. Is it possible?
If yes, please suggest how to proceed.
Your help is highly appriciable.
Regards
Vivekhi
Use User Exit :QPL10001
Description
You can use this enhancement to change all the fields when creating an
inspection lot. The function module is only run once.
You must be careful when using this enhancement since this can lead to
inconsistencies in inventory management. For example, if you change the
quantity fields.
Logic:
Logic will be when you are using a specific Material say MATNR : xyz .......then disable the Qty field LOSMENGE.
I hope this will help you
Regards
Sujit -
Best Practice with States and lots of code lines
Hi.
This is my first application in flex.
I'm ok with as3.
Now, in as3 we were 'forced' to work mostly with external classes so hardly we have a unique code page with lots of lines.
In flex, using States leads to build codes with lots of line IF we think on states as web site pages.
I'm not sure it I understand it right. You mean: if an user visits a website built with 10 pages, but the users access only 2 pages, all that 8 remaining pages would have to be download to the swf the user loads? (this is, considering the usage os states as pages)
I'm building a system where the user logs to use it.
2 states at now: login page and home page.
I access the db, and get the user and password with this event dispatched from the db.result (this works, however i found it too-old-style looping. Is there a better way, of course, which?)
protected function usersService_resultHandler(event:ResultEvent):void
allUsers = event.result as ArrayCollection;
for (var i:uint;i<allUsers.length;i++){
if(allUsers[i].user == tx_user.text && allUsers[i].password == tx_password.text)
currentState = "home";
else
Alert.show("Fault", "Login");
While I have start to build the "home" page/state, I realized that my code would dramatcally increase. Is it the best practice? Do I have to call another url after login (to open a Session - please, some Session tutorials in flex)? Or I keep doing all in states? I'm afraid my swf would grow bigger.
ThanksOk.
The problem is that I'm not used to PHP, and I have generated the code to deal with the server automatically via Flex.
However I could add a new function, and I could guess how to catch values in the db to compare.
its a frankenstein function, but i'm afraid it also works. By now, there is no way to know whether user mistyped password or username.
public function getUserVerification($user, $pass) {
$stmt = mysqli_prepare($this->connection, "SELECT user, password FROM $this->tablename where user=? AND password=?");
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, 'ss', $user, $pass);
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
mysqli_stmt_bind_result($stmt, $row->user, $row->password);
if(mysqli_stmt_fetch($stmt)) {
return 1;
} else {
return 0;
Also I had to update the _Super_UsersService.as Class flex had generated before when I first created a php code to deal with db.
Finaly, I had to assign return and input types for the new function I've created.
Amazing... it works.
Now, when pressing the submit button on the login, flex sends user and password so php compare them instead looping it in a Array.
Also, I have made all this code inside a "loginView" component. So my main app is clean again.
I guess I understand the idea of using components and reusing them as many as possible. I just have to get used to how to access a component value from outside and vice-versa.
Now, the creationPolicy is something I would look for. This might be interesting.
Thanks a lot.
Btp~ -
I work at a nonprofit, and we've just been given a new
website provided to us by a team of volunteers. However, the
template has some minor typos that I need to fix. Whenever I save
the template, I get error after error, primarily along the lines of
"Unbalanced #EndEditable tag" or "Nested Editable Regions," but
some others have popped up, too. I can't ignore the error, either,
because the rest of the pages in the site won't update.
The volunteer team was working in two different versions of
Dreamweaver, and the following part of the code seems to be source
of several of the problems. There's two different versions of the
"begineditable" and "endeditable tags," with a section beginning
with "#begineditable" and then containing a
"templatebegineditable." When I try to standardize the tags or
remove them from within each other, the content region drops to
below the left nav. I don't understand what's happenning, or how to
fix it. Any ideas?
Thanks,
Jodi
<!-- BeginEditable "leftnav" -->
<table width="205" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td height="32" align="center"
background="../IMAGES/left_nav_top.gif" bgcolor="#FFFFFF"
class="nav_links">
<!-- TemplateBeginEditable name="left_nav_title" -->
<table width="190" border="0" align="left"
cellpadding="0" cellspacing="0">
<tr>
<td class="nav_links_title">About Page </td>
</tr>
</table>
<!-- TemplateEndEditable -->
</td>
</tr>
<tr>
<td align="center" valign="top"
background="../IMAGES/left_nav_middle.gif" class="text">
<!-- TemplateBeginEditable name="left_nav_sections"
-->
<table width="190" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td height="25"><img
src="../images/button-arrow.gif" width="13" height="13"><span
class="nav_links">About
Us </span></td>
</tr>
<tr>
<td height="25"><img
src="../images/button-arrow.gif" width="13" height="13"><span
class="nav_links">Board
of Directors </span></td>
</tr>
<tr>
<td height="25"><img
src="../images/button-arrow.gif" width="13" height="13"><span
class="nav_links">Meet
Our Staff </span></td>
</tr>
<tr>
<td height="25"><img
src="../images/button-arrow.gif" width="13" height="13"><span
class="nav_links">Partners</span></td>
</tr>
<tr>
<td height="25"><img
src="../images/button-arrow.gif" width="13" height="13"><span
class="nav_links">Funding
and Financials </span></td>
</tr>
</table>
<!-- TemplateEndEditable -->
</td>
</tr>
<tr>
<td height="32" align="center" valign="top"
background="../IMAGES/left_nav_bottom.gif"
class="text""> </td>
</tr>
</table>
<!-- #EndEditable -->
<table width="205" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td height="32" background="../IMAGES/left_nav_top.gif"
bgcolor="#FFFFFF" class="nav_links"><font color="#000000"
class="nav_links_title">What's your
Footprint?</font></td>
</tr>
<tr>
<td background="../IMAGES/left_nav_middle.gif"
class="text">
<p><a href="
http://www.myfootprint.org"
target="_blank"><img src="../images/logo_eco_fp.gif"
width="180" height="80" border="0"></a>
</td>
</tr>
<tr>
<td background="../IMAGES/left_nav_middle.gif"
class="text"><a href="
http://www.officefootprint.org"
target="_blank"><img src="../images/logo_off_fp.gif"
width="180" height="26" border="0"></a></td>
</tr>
<tr>
<td background="../IMAGES/left_nav_middle.gif"
class="text"><a href="
http://www.kidsfootprint.org"
target="_blank"><img src="../images/logo_kid_fp.gif"
width="180" height="28" border="0"></a></td>
</tr>
<tr>
<td background="../IMAGES/left_nav_middle.gif"
class="text"><a href="
http://www.ecologicalfootprint.org"
target="_blank"><img src="../images/logo_nat_fp.gif"
width="180" height="51" border="0"></a></td>
</tr>
<tr>
<td background="../IMAGES/left_nav_bottom.gif"
class="text"> </td>
</tr>
<tr>
<td height="32" background="../IMAGES/left_nav_top.gif"
bgcolor="#FFFFFF" class="nav_links"><font color="#000000"
class="nav_links_title">Learn about
EJCC </font></td>
</tr>
<tr>
<td background="../IMAGES/left_nav_middle.gif"
class="text"><a href="
http://www.ejcc.org"
target="_blank"><img src="../images/logo_ejcc.gif"
width="180" height="60" border="0"></a></td>
</tr>
<tr>
<td height="14"
background="../IMAGES/left_nav_bottom.gif"
class="text"> </td>
</tr>
</table> </td>
<td width="803"> <!-- #BeginEditable "content"
-->
<table width="763" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td height="31"
background="../images/content_top.gif"> </td>
</tr>
<tr>
<td background="../images/content_middle.gif">
<!-- TemplateBeginEditable name="content" -->
<table width="760" height="491" border="0"
cellpadding="0" cellspacing="0">
<tr>
<td class="text"> </td>
</tr>
</table>
<!-- TemplateEndEditable -->
</td>
</tr>
<tr>
<td height="31"
background="../images/content_bottom.gif"> </td>
</tr>
</table>
<!-- #EndEditable --></td></table>
<!-- #EndEditable --></td>
I think somebody worked on the page with dw3 or dw4.
If the code you showed was from the Template, it should work
if you strip
out the #BeginEditable and #EndEditable and leave the
TemplateBegin and
TemplateEnd.
Then scan the code to see if all template syntax is correct,
and everything
you need to edit is in an Editable region. dw
menu-->modify-->Templates-->Check template syntax.
My guess is the dw4 person made one big editable area, and
the MX or newer
person put in a group of distinct editable areas that are now
nested inside
the old template syntax editable area.
Strong Suggestion- Make a backup copy of the site's Local
Site Folder before
doing anything- template syntax problems can cause loss of
content.
Alan
Adobe Community Expert, dreamweaver
http://www.adobe.com/communities/experts/ -
Reversi GUI question, A LOT of code in here!
okay, so I've been working on his code for a long time. A REAL long time, working on it bit by bit, and all I got left is the Reversi's GUI. Basically I want to use the Jbutton and have x represent black and o represent white. I'm getting stuck on how to go about it. Any ideas?
Here's alllll the code.
package com.Ozo.games.reversi;
* This utility class provides a number of static constants and
* methods that provide abstractions for player colors and moves.
* Colors and moves could be implemented as objects of separate
* classes, but instead we represent them as integers and provide
* the abstraction via these operations.
public class Reversi {
public static final int Black = 1;
public static final int White = 2;
public static final int Empty = 0;
* Gives the color of a player's opponent.
* @param color of this player.
* @return color of the opponent.
public static int playerOpposite(int color) {
if (color == Black) return White;
if (color == White) return Black;
throw new Error("Player must be Black or White");
* Compare two scores and determine whether the first is better than the second.
* Better for black means more positive. Better for white means more negative.
* @param colorAsking
* @param score1
* @param score2
* @return whether score1 is better than score2, as far as colorAsking is concerned.
public static boolean isBetterScore(int colorAsking, int score1, int score2) {
if (colorAsking == Black) return score1 > score2;
if (colorAsking == White) return score1 < score2;
throw new Error("Player must be Black or White");
* Encode a move from this position as an integer.
* A "pass" move is recorded as (-1,-1).
* @param pos the board this move is for.
* @param row the row at which the piece is placed.
* @param col the column at which the piece is placed.
* @return encoded move.
public static int newMove(ReversiPosition pos, int row, int col) {
return row * pos.ncols() + col;
* A "pass" move. I.e. no piece is placed.
public static int newMovePass(ReversiPosition pos) {
return newMove(pos, -1, -1);
* Find the row of an encoded move.
* @param pos the board this move is for.
* @param move
* @return the row.
public static int moveRow(ReversiPosition pos, int move) {
return move / pos.ncols();
* Find the column of an encoded move.
* @param pos the board this move is for.
* @param move
* @return the column.
public static int moveCol(ReversiPosition pos, int move) {
return move % pos.ncols();
package com.Ozo.games.reversi;
* Top-level driver for a Reversi game.
public class ReversiGame {
private ReversiPosition _pos;
private int _toMoveColor;
private ReversiTextIO _userInterface;
public ReversiGame(int nrows, int ncols) {
_pos = new ReversiPosition(nrows, ncols);
_toMoveColor = Reversi.Black;
_userInterface = null;
ReversiRules.setStartingPosition(_pos);
public void setUserInterface(ReversiTextIO ui) {
_userInterface = ui;
public ReversiPosition currentPosition() { return _pos; }
public int toMoveColor() { return _toMoveColor; }
public void getHumanMoveAndApplyIt() {
if (ReversiRules.countLegalMoves(_pos, _toMoveColor) != 0) {
int move = _userInterface.getMove(_pos, _toMoveColor);
_pos.applyMove(move, _toMoveColor);
else
_userInterface.message("You have no move. I get another turn.");
_toMoveColor = Reversi.playerOpposite(_toMoveColor);
public void getComputerMoveAndApplyIt() {
if (ReversiRules.countLegalMoves(_pos, _toMoveColor) != 0) {
int move = ReversiStrategy.findBestMove(_pos, _toMoveColor);
_pos.applyMove(move, _toMoveColor);
else
_userInterface.message("I have no move. You get another turn.");
_toMoveColor = Reversi.playerOpposite(_toMoveColor);
public void play() {
_userInterface.output(_pos);
for (;;) {
if (ReversiRules.isGameOver(_pos, _toMoveColor)) { gameOverMessage(); break; }
getHumanMoveAndApplyIt();
_userInterface.output(_pos);
if (ReversiRules.isGameOver(_pos, _toMoveColor)) { gameOverMessage(); break; }
getComputerMoveAndApplyIt();
_userInterface.output(_pos);
public void gameOverMessage() {
_userInterface.message("Game over...");
int winner = ReversiRules.winningColor(_pos, _toMoveColor);
if (winner == Reversi.Black) _userInterface.message("Black wins.");
else if (winner == Reversi.White) _userInterface.message("White wins.");
else _userInterface.message("Draw.");
package com.Ozo.games.reversi;
* The main class to start a Reversi game as an application.
public class ReversiMain {
public static void main(String[] args) {
ReversiGame game = new ReversiGame(8, 8);
ReversiTextIO tui = new ReversiTextIO(System.in, System.out);
game.setUserInterface(tui);
game.play();
}package com.Ozo.games.reversi;
* This class provides all of the intelligence for a program to play Reversi.
* It contains all the knowledge of play strategy. (The knowledge of the rules
* is maintained by the ReversiRules class.)
* The principal method is findBestMove, which does an exhaustive search a number
* of plys deep, and then applies a hueristic position evaluation function.
public class ReversiStrategy {
private static int PlysToTry = 6;
* Find the best move for the player of the given color.
* If there is no move, then return "pass".
* @param pos the position to be evaluated.
* @param toMoveColor the color of player to move.
* @param plysRemaining the depth to examine (must be >= 1).
* @return the best move within the default horizon.
public static int findBestMove(ReversiPosition pos, int toMoveColor) {
return findBestMove(pos, toMoveColor, PlysToTry).move;
* This class is used to return a pair of values: the best move and the score it achieves
* after the number of plys remaining are played.
public static class BestMove {
public int move;
public int score;
public BestMove(int m, int s) { move = m; score = s; }
* Find the best move for the player of the given color within
* the given number of plys.
* @param pos the position to be evaluated.
* @param toMoveColor the color of player to move.
* @param plysRemaining the depth to examine (must be >= 1).
* @return a BestMove object returning the best move found and the score it achieves.
public static BestMove findBestMove(ReversiPosition pos, int toMoveColor, int plysRemaining) {
if (plysRemaining < 1) throw new Error("findBestMove needs plysRemaining >= 1");
// Generate the legal moves. If there are none, then pass.
int opponentColor = Reversi.playerOpposite(toMoveColor);
int[] moves = ReversiRules.generateMoves(pos, toMoveColor);
if (moves.length == 0) {
if (plysRemaining == 1)
return new BestMove(Reversi.newMovePass(pos), summaryScore(pos));
else
return findBestMove(pos, opponentColor, plysRemaining-1);
// Try all the moves. Re-use one position object to make the move.
ReversiPosition afterMove = pos.copy();
// Start with a hypothetical worst scenario and then look for what's better.
afterMove.fill(opponentColor);
int bestScore = 2*summaryScore(afterMove); // Worse that the worst possible real score.
int bestIndex = -1;
for (int i = 0; i < moves.length; i++) {
pos.copyInto(afterMove); // Re-use the position object.
afterMove.applyMove(moves, toMoveColor);
int thisScore = (plysRemaining == 1) ?
summaryScore(afterMove) :
findBestMove(afterMove, opponentColor, plysRemaining - 1).score;
if (Reversi.isBetterScore(toMoveColor, thisScore, bestScore)) {
bestScore = thisScore;
bestIndex = i;
if (bestIndex == -1) System.out.println("Number of moves " + moves.length + " plys " + plysRemaining);
return new BestMove(moves[bestIndex], bestScore);
* Examine contents of square and return 1 for Black, -1 for White, 0 for Empty.
* Useful in computing scores.
* @param r row number.
* @param c column number.
* @return +1/-1/0
private static int squareVal(ReversiPosition pos, int r, int c) {
if (pos.getSquare(r, c) == Reversi.White) return -1;
if (pos.getSquare(r, c) == Reversi.Black) return +1;
return 0;
* Count the number of black squares minus the number of white squares.
* @return difference in number of black and white squares.
public static int squareScore(ReversiPosition pos) {
int nBminusW = 0;
for (int r = 0; r < pos.nrows(); r++)
for (int c = 0; c < pos.ncols(); c++)
nBminusW += squareVal(pos, r, c);
return nBminusW;
* Count the number of black edge squares minus the number of white ones.
* @return difference in number of black and white squares.
public static int edgeScore(ReversiPosition pos) {
int nBminusW = 0;
// East and west edges.
for (int r = 1; r < pos.nrows()-1; r++)
nBminusW += squareVal(pos, r, 0) + squareVal(pos, r, pos.ncols()-1);
// North and south edges.
for (int c = 1; c < pos.ncols()-1; c++)
nBminusW += squareVal(pos, 0, c) + squareVal(pos, pos.nrows()-1, c);
return nBminusW;
* Count the number of black corner squares minus the number of white ones.
* @return difference in number of black and white squares.
public static int cornerScore(ReversiPosition pos) {
int rlast = pos.nrows()-1, clast = pos.ncols()-1;
return squareVal(pos, 0, 0) + squareVal(pos, 0, clast) +
squareVal(pos, rlast, 0) + squareVal(pos, rlast, clast);
* Compute a heuristic score for a given position. The more positive,
* the better for Black. Controlling corners is weighted most heavily,
* folowed by sides, then regular squares. In principle a different weight
* function should be used at the end of the game, since then it is really
* the total number of squares that counts.
* @param pos the position to be assessed.
* @return the numerical score, with positive being good for Black, negative good for White.
public static int summaryScore(ReversiPosition pos) {
return squareScore(pos) + 8*edgeScore(pos) + 20*cornerScore(pos);
}Edited by: Oozaro on Nov 19, 2009 12:41 PM -
Lots of code, Little problem....
Does anyone have how to get this program to run this line when the close box is pressed:
userClosed("Connection Closing.", isC);
This line sends that message to the other client program connected to it. I can get this line to run when the menu exit selection is called, but when the close box is pushed, nothin?
This was a possible fix and from what I can tell should have worked. I'm trying to add some lines that say:
Runtime.getRuntime().addShutdownHook(new Thread()
public void run()
userClosed("Connection Closing.", isC);
});But for Some reason it doesn't seem to be working? I know the above code is valid, it works in other programs.
The other possible fix is:
When the Admin's default constructor is called, it is called from another program that MUST be kept running. When the Admin's client program shuts down I'm using a dispose() to protect the calling program from being shutdown. If someone can tell me how to shutdown this program without killing the calling program, that might work too.
Thanks!
/* A simple Swing based client that talks to the Switch */
import javax.swing.*;
import java.io.*;
import java.net.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
public class TrialClient extends JFrame implements GMReceiver //-------------
JTextField userText = new JTextField(40);
JTextArea log = new JTextArea(24,40);
JPanel outPanel = new JPanel();
JScrollPane logScroll = new JScrollPane(log);
JMenuBar menuBar = new JMenuBar();
JMenuItem startItem = new JMenuItem("Start");
JMenuItem hostItem = new JMenuItem("Host");
JMenuItem aboutItem = new JMenuItem("About");
JMenuItem exitItem = new JMenuItem("Exit");
JMenu fileMenu = new JMenu("File");
JMenu helpMenu = new JMenu("Help");
Container cp;
RemoteUser remote;
String address="genesis.zedxinc.com";
int port1=8000; int port2 = 8001; int port = 0;
boolean running;
int isC; Socket contin; int isApp;
TrialClient() //Client Default Constructor-------------------------------
isC = 0;
port = port1;
String userName = JOptionPane.showInputDialog
(null, "Please Enter Your Name:", "ZedX Web Messenger", JOptionPane.QUESTION_MESSAGE);
buildMenu();
cp = getContentPane();
log.setEditable(false);
outPanel.add(new JLabel("Send: "));
outPanel.add(userText);
userText.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent evt){userTyped(evt);}});
cp.setLayout(new BorderLayout());
cp.add(outPanel,BorderLayout.NORTH);
cp.add(logScroll,BorderLayout.CENTER);
userName = "Client: " + userName;
setTitle(userName);
addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent evt){mnuExit();}});
toLog("!! use start menu to start");
toLog("!! host is "+address+":"+port1);
pack();
TrialClient(JApplet a) //Web Client Default Constructor-------------------------------
isC = 0;
isApp = 1;
port = port1;
String userName = JOptionPane.showInputDialog
(null, "Please Enter Your Name:", "ZedX Web Messenger", JOptionPane.QUESTION_MESSAGE);
buildMenu();
cp = getContentPane();
log.setEditable(false);
outPanel.add(new JLabel("Send: "));
outPanel.add(userText);
userText.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent evt){userTyped(evt);}});
cp.setLayout(new BorderLayout());
cp.add(outPanel,BorderLayout.NORTH);
cp.add(logScroll,BorderLayout.CENTER);
userName = "Client: " + userName;
setTitle(userName);
addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent evt){mnuExit();}});
toLog("!! use start menu to start");
toLog("!! host is "+address+":"+port1);
pack();
TrialClient(String s, Socket myServer) //Admin Default Constructor-------
isC = 1;
port = port2;
String userName = s;
contin = myServer;
buildMenu();
cp = getContentPane();
log.setEditable(false);
outPanel.add(new JLabel("Send: "));
outPanel.add(userText);
userText.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent evt){userTyped(evt);}});
cp.setLayout(new BorderLayout());
cp.add(outPanel,BorderLayout.NORTH);
cp.add(logScroll,BorderLayout.CENTER);
userName = "Admin: " + userName;
setTitle(userName);
addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent evt){mnuExit();}});
toLog("!! use start menu to start");
toLog("!! host is "+address);
pack();
mnuStart();
void RunShutdown()
Runtime.getRuntime().addShutdownHook(new Thread()
public void run()
userClosed("Connection Closing.", isC);
void userTyped(ActionEvent evt) //----------------------------------------
String txt = evt.getActionCommand();
userText.setText("");
toLog(txt, true);
System.out.println("From user:"+txt);
if(running)remote.postMessage(txt);
void userClosed(String evt, int who) //----------------------------------------
String txt = evt;
boolean istf = true;
userText.setText("");
toLog(txt, istf);
System.out.println("From user:"+txt);
if(running)remote.postMessage(txt);
void toLog(String txt){toLog (txt,false);} //-----------------------------
void toLog(String txt, boolean user) //-----------------------------------
log.append((user?"> ":"< ")+txt+"\n");
log.setCaretPosition(log.getDocument().getLength() );
// build the standard menu bar
void buildMenu() //-------------------------------------------------------
JMenuItem item; // file menu
startItem.addActionListener(new ActionListener()
{public void actionPerformed(ActionEvent e){mnuStart();}});
fileMenu.add(startItem);
hostItem.addActionListener(new ActionListener()
{public void actionPerformed(ActionEvent e){mnuHost();}});
fileMenu.add(hostItem);
exitItem.addActionListener(new ActionListener()
{public void actionPerformed(ActionEvent e){mnuExit();}});
fileMenu.add(exitItem);
menuBar.add(fileMenu);
helpMenu.add(aboutItem);
aboutItem.addActionListener(new ActionListener()
{public void actionPerformed(ActionEvent e){mnuAbout();}});
menuBar.add(helpMenu);
setJMenuBar(menuBar);
void mnuStart() //--------------------------------------------------------
Runtime.getRuntime().addShutdownHook(new Thread()
public void run()
userClosed("Connection Closing.", isC);
if(!running)
if (isC == 0)
remote = new RemoteUser(this, address, port);
else
remote = new RemoteUser(this, contin, isC);
if(remote.start())
startItem.setText("Stop");
running = true;
else remote = null;
else
userClosed("Connection Closing.", isC);
remote.stop();
remote = null;
running = false;
startItem.setText("Start");
void mnuHost() //----------------------------------------------------------
String txt = JOptionPane.showInputDialog("Enter host address and port");
if (txt == null)return;
int n = txt.indexOf(':');
if(n == 0)
address = "genesis.zedxinc.com";
port = toInt(txt.substring(1),8000);
else if(n < 0)
address = txt;
port = 8000;
else
address = txt.substring(0,n);
port = toInt(txt.substring(n+1),8000);
toLog("!! host set to "+address+":"+port);
// setTitle(userName);
void mnuAbout() //---------------------------------------------------------
new AboutDialog(this).show();
System.out.println("about called");
void mnuExit() //----------------------------------------------------------
userClosed("Connection Closing.", isC);
// toLog("!! use start menu to start");
if (isC == 1){
if(remote != null)remote.close();
dispose();
// System.exit(0);
else if (isApp == 1)
this.destroy();
if(remote != null)remote.close();
System.exit(0);
else
if(remote != null)remote.close();
System.exit(0);
public void dispose() { //------------------------------------------------
switch (this.getDefaultCloseOperation()) {
case DISPOSE_ON_CLOSE:
super.dispose();
break;
public void fromHost(String txt){postGMessage(new GUIMessage(this,txt));} //---------
public void runGMessage(GUIMessage gm){toLog((String)gm.dat);} //--------------------
public void postGMessage(GUIMessage gm){SwingUtilities.invokeLater(gm);} //----------
public static int toInt(String s, int er) //----------------------
int i;
try{i = new Integer(s).intValue();}
catch(NumberFormatException exc){i = er;}
return i;
class AboutDialog extends JDialog //-----------------------------------
Container contentPane;
JTextField text = new JTextField("Simple character client");
AboutDialog(Frame f)
super(f,"About TrialClient",true);
contentPane = getContentPane();
contentPane.add(text);
pack();
class RemoteUser //----------------------------------------------------
Socket sock;
BufferedReader in;
BufferedWriter out;
TrialClient parent;
String name ="";
int state = 0;
Thread recvThread;
Thread sendThread;
LinkedList sendQ = new LinkedList();
boolean signedOn = false;
String address; int port; int isc;
RemoteUser(TrialClient c, String a, int p) //----------------------
parent = c;
address = a;
port = p;
RemoteUser(TrialClient c, Socket s, int isC) //---------------------
parent = c;
sock = s;
isc = isC;
boolean start() //---------------------------------------------------
try
state = 1;
if (isc == 0)
sock = new Socket(address,port);
name = getAddress();
in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
out = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream()));
recvThread = new Thread(new Runnable()
{public void run(){doRecv();}},"Recv");
sendThread = new Thread(new Runnable()
{public void run(){doSend();}},"Send" );
sendThread.start();
recvThread.start();
parent.fromHost ("!! Connected to = "+name);
state = 2;
catch(Exception e)
parent.fromHost ("!! Connection failed to = "+name);
e.printStackTrace();
close();
return state == 2;
void stop(){close();} //-----------------------------------------------
void doSend() //-------------------------------------------------------
String msg;
try
while (null != (msg = popMessage()))
System.out.println("sending ("+msg+") to user="+name);
out.write(msg+"\r\n");
out.flush();
catch(Exception e){e.printStackTrace();}
synchronized String popMessage() //---------------------------------------
String msg = null;
while (state > 0 && sendQ.size() == 0)
try{this.wait();}
catch(InterruptedException e){}
if(state > 0)msg = (String)sendQ.remove(0);
return msg;
synchronized void postMessage(String msg) //------------------------------
sendQ.add(msg);
this.notify();
void doRecv() //----------------------------------------------------------
String inbuf;
while (0 != state)
try{inbuf = in.readLine();}
catch(Exception e){inbuf = null;}
if(inbuf == null)close();
else
System.out.println("received ("+inbuf+") from user="+name);
parent.fromHost(inbuf);
void close() //----------------------------------------------------------
int s = state;
state = 0;
if(sock != null)
if (sendThread != null && sendThread.isAlive())sendThread.interrupt();
if(s == 0)parent.fromHost("!! closed");
else{ parent.fromHost("!! closing user "+name); }
try{sock.close();}
catch(Exception e){e.printStackTrace();}
String getAddress(){return ""+sock.getInetAddress()+":"+sock.getPort(); }
interface GMReceiver //----------------------------------------------------------
public void runGMessage(GUIMessage gm);
public void postGMessage(GUIMessage gm);
class GUIMessage implements Runnable //------------------------------------------
GMReceiver gui;
Object dat;
GUIMessage(GMReceiver gui, Object dat)
this.dat = dat;
this.gui = gui;
public void run()
gui.runGMessage(this);
}How about interface java.awt.WindowListener???
Sure can help you out!
"windowOpened
public void windowOpened(WindowEvent e)
Invoked the first time a window is made visible.
windowClosing
public void windowClosing(WindowEvent e)
Invoked when the user attempts to close the window from the window's system menu. If the program does not explicitly hide or dispose the window while processing this event, the window close operation will be cancelled.
windowClosed
public void windowClosed(WindowEvent e)
Invoked when a window has been closed as the result of calling dispose on the window.
windowIconified
public void windowIconified(WindowEvent e)
Invoked when a window is changed from a normal to a minimized state. For many platforms, a minimized window is displayed as the icon specified in the window's iconImage property.
See Also:
Frame.setIconImage(java.awt.Image)
windowDeiconified
public void windowDeiconified(WindowEvent e)
Invoked when a window is changed from a minimized to a normal state.
windowActivated
public void windowActivated(WindowEvent e)
Invoked when the Window is set to be the active Window. Only a Frame or a Dialog can be the active Window. The native windowing system may denote the active Window or its children with special decorations, such as a highlighted title bar. The active Window is always either the focused Window, or the first Frame or Dialog that is an owner of the focused Window.
windowDeactivated
public void windowDeactivated(WindowEvent e)
Invoked when a Window is no longer the active Window. Only a Frame or a Dialog can be the active Window. The native windowing system may denote the active Window or its children with special decorations, such as a highlighted title bar. The active Window is always either the focused Window, or the first Frame or Dialog that is an owner of the focused Window.
" -
Lots of code to make a web service
Does anybody know of any tools to make creating web services faster in Java - I am getting frustrated with the amount of code it takes. Anybody else feel the same way?
Here's an example of what I mean..
// Open a database connection and statement.
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();
Connection dbConn = DriverManager.getConnection("jdbc:db2:sample","myuser","mypass");
Statement statement = dbConn.createStatement();
// Build the message.
SOAPMessageContext ctx = (SOAPMessageContext) messageContext;
try {
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage m = messageFactory.createMessage();
SOAPEnvelope env = m.getSOAPPart().getEnvelope();
SOAPBody body = env.getBody();
SOAPElement elem =
body.addBodyElement(env.createName("ns1:getEmployees"));
elem.addNamespaceDeclaration("ns1",
"http://www.abc.com/SampleApplication/Employee.wsdl");
elem.addNamespaceDeclaration("ns2",
"http://www.abc.com/SampleApplication/Employee.xsd");
SOAPElement elem1 = new SOAPElementImpl("Response", null, null);
// Execute the query.
String sql = "SELECT EMPNO, FIRSTNME, MIDINIT, LASTNAME, HIREDATE FROM EMPLOYEE";
ResultSet result = statement.executeQuery(sql);
SOAPElement employee = new SOAPElementImpl("Employees", "ns2", "http://www.abc.com/SampleApplication/Employee.xsd");
employee.addChildElement("ns2:EMPNO").addTextNode(result.getString("EMPNO"));
employee.addChildElement("ns2:FIRSTNME").addTextNode(result.getString("FIRSTNME"));
employee.addChildElement("ns2:FIRSTNME").addTextNode(result.getString("MIDINIT"));
employee.addChildElement("ns2:LASTNAME").addTextNode(result.getString("LASTNAME"));
employee.addChildElement("ns2:FIRSTNME").addTextNode(result.getString("HIREDATE"));
elem1.addChildElement(employee);
elem.addChildElement(elem1);
ctx.setMessage(m);
dbConn.close();
} catch (Throwable e) {
weblogic.utils.Debug.say("(hbs):e " + e);
e.printStackTrace(System.out);
putting the data in the node seems excessive to me.
thanks
DG -
Showing different numbers with out a lot of code
My assignment is to list the loan balance and interest paid for each payment over the term of the loan.
The loan amount is for $200,000 at 5.75% for 360 months. Ill figure out the math part but how do I code so that it prints out the differerent principle balances for each month with out doing it 360 times for 360 months?
Of course I wont have to code all 360 payments. So for example lets say the total loan amount is for $100 and and the interest is 1%. I pay $9 to the principle and $1 for the interest the first month, the next month there is $91 left on the principle etc etc. How do I show that?
I am just learning java so the more basic the code the better off for me.
thanks in advance!!Presumably you are taking a class in Java so the instructor should have covered loop structures for this assignment.
But here are some references just in case:
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/while.html
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/for.html -
Lots of code clean-up / inclusion paths throwing errors.
I just built a test app and I am getting errors all over the place.
First, every page has an include with the 'virtual' method. IE... virtual('/Connections/conNightclub.php');
I need this to be include ('Connections/conNightclub.php');
I also noticed that some paths to includes have a forward slash and some don't. ie.. require_once ('/includes/mxi/MXI.php'); should be require_once ('includes/mxi/MXI.php')
Then, when I fix them by hand the server behavior panel gets exclamation points next to the transactions.
I hope this is something I forgot to set somewhere...Hi,
>>
First, every page has an include with the 'virtual' method
>>
seems you´re getting this error because
(that´s a rather rare case) PHP has been configured as Apache CGI module on your remote server -- "virtual" won´t work then, means you´ll have to change it to "include" yourself
Günter Schenk
Adobe Community Expert, Dreamweaver -
Lots of code when I boot - what is going on here?
I just installed 10.4.10 ...
(click me - flickr link to hi-res pic)
I'm not sure what's happening here. my new mac book pro does this every time I try booting it up and just when I think it's frozen (after about two minutes) it gives me the login window. not a lethal issue but still disturbing.
osx 10.4.10
2ghz intel core duo
1.6 GB ram
Message was edited by: memos to the futureSounds like you are stuck in "verbose" mode.
http://docs.info.apple.com/article.html?artnum=106388
You should start up from the Mac OS X Installation Disk, from the Installer menu, run Disk Utility. Run both Repair and Repair Permissions routines on the First Aid tab. You can run Disk Utility after starting normally, but you cannot run the Repair routine.
If that does not resolve the problem, try resetting the PRAM
http://docs.info.apple.com/article.html?artnum=2238 -
PL/SQL Packages that have lots of Remarked code
Thanks in advance,
Does having lots of code that is remarked in PL/SQL packages take up space in the database and impact performance ?
I have inherited a system that has lots of remarked code in PL/SQL Packages. And I would like to know if I should remove it with an advantage of improving preformance?Does "remarked" here refer to comments in the code? If so, there is no meaningful performance impact to having comments in the code and substantial maintenance benefits, so you shouldn't be removing comments. You should be quite appreciative that you've inherited a system that is reasonably well documented.
Justin -
Why can't I read a lot of my mail?
does anyone else have this problem: at least a third to a half of all the eMails I receive on the iPhone come in a completely unreadable form - a lot of code, or a message that I can't decipher. Not just one or two, but a good portion of everything.
I hated my old treo in every other respect - it couldn't do anything that the iP can - but I have to admit, the old 3-o seems to have done a simpler & better job of reading eMail.
is there any way I can set the iPhone to let me read eMail in a text-only mode? Some kind of non-HTML mode? I don't need fancy formatting & pictures, just raw text will do it!
wI have not experienced the same and I recieve messages that were composed with HTML or a message forwarded that was composed with HTML with no problems.
The iPhone's email client does not include a setting to covert all message formatting to Plain Text.
Does this occur primarily with one sender or any/all?
If one or two, you can ask these senders to configure their email client settings to always send you messages in Plain Text - Outlook includes this option by individual contacts in the address book. HTML composition for email is something Microsoft wrought upon the internet which is fraught with potential problems and security issues for Windows users and for Mac users but to a much lessor degree. If only Plain Text was supported for email exchange, it would be boring for some but most if not all problems associated with the exchange of email and email attachments would be eliminated.
I also suggest deleting and manually recreating this account on your iPhone. -
Here is my situation. I have a table that has a list of codes almost 100K. I have another table that has code listed in term of an in house regular expression.
Example:
40a.[1,2,3]
12b
Where
a is 0 - 9
b is 1 - 9
I have tried using REGEXP_LIKE but I get ORA-04030: out of process memory error.
My question is there a way to do this search such that it will be fast and efficient.
I have through about expanding the Expressed code, but that could lead to a lot of codes, and it specially gets tricky if the code is in the format of "1a2b". In this case I would need to somehow create 90 (10*9) rows. I am not entriely sure how to do this dynamically, because there could be a lot of variations.
The current approcach I am thinking of is to search based on character placement. Such that each character becomes a column and I do the comparisson as
Base_Char_1 = Code_Exp_1
Base_Char_2 = Code_Exp_2
I have not figured out how this would work. Shown below is the REGEXP_LIKE approach. Any help or advice would be great.
WITH t1 AS
(SELECT '40a.[0,1,9]1' AS code_exp
FROM DUAL
), t2 AS
(SELECT code_exp
, '^' || REPLACE (REPLACE (REPLACE (REPLACE (code_exp, 'a', '[0-9]'), '.', '\.'), 'b', '[1-9]'), ',') || '$' AS code_regexp
FROM t1)
SELECT *
FROM t2
WHERE REGEXP_LIKE ('402.11', code_regexp)Thanks.Well, it is probably a design issue - joining 100 000 codes with 10 000 regular expressions based on regexp_like() will effectively mean 1e9 calculated regular expressions, which means a lot of work i suppose.
Besides that, there is indeed something strange on pga/uga memory consumption when regular expressions are stored in the table. I've set up small test case based on your data
SQL> CREATE TABLE codes AS
2 SELECT dbms_random.string('p',10) code
3 FROM dual
4 CONNECT BY LEVEL <=100000
5 UNION ALL
6 SELECT '402.11' FROM dual
7 /
Table created.
SQL> CREATE TABLE code_expressions AS
2 WITH t1 AS
3 (SELECT '40a.[0,1,9]1' AS code_exp
4 FROM DUAL
5 ), t2 AS
6 (SELECT code_exp, '^' ||
7 REPLACE (REPLACE (REPLACE (REPLACE (code_exp, 'a', '[0-9]'), '.', '\.'), 'b', '[1-9]'), ',')
8 || '$' AS code_regexp
9 FROM t1)
10 SELECT * FROM t2
11 /
Table created.
SQL> exec dbms_stats.gather_table_stats(user,'codes')
PL/SQL procedure successfully completed.
SQL> exec dbms_stats.gather_table_stats(user,'code_expressions')
PL/SQL procedure successfully completed.
SQL> set lines 100
SQL> col code for a15
SQL> col code_exp for a15
SQL> col code_regexp for a25
SQL> exec runStats_pkg.rs_start;
PL/SQL procedure successfully completed.
SQL> SELECT * FROM codes,code_expressions WHERE regexp_like(code,'^40[0-9]\.[019]1$');
CODE CODE_EXP CODE_REGEXP
402.11 40a.[0,1,9]1 ^40[0-9]\.[019]1$
SQL> exec runStats_pkg.rs_middle;
PL/SQL procedure successfully completed.
SQL> SELECT * FROM codes,code_expressions WHERE regexp_like(code,code_regexp);
CODE CODE_EXP CODE_REGEXP
402.11 40a.[0,1,9]1 ^40[0-9]\.[019]1$
SQL> exec runStats_pkg.rs_stop;
Run1 ran in 34 hsecs
Run2 ran in 276 hsecs
run 1 ran in 12.32% of the time
Name Run1 Run2 Diff
STAT...session cursor cache co 1 0 -1
.... sniped
STAT...CPU used when call star 37 276 239
STAT...CPU used by this sessio 37 276 239
STAT...DB time 37 277 240
STAT...Elapsed Time 36 283 247
STAT...session pga memory 65,536 0 -65,536
STAT...session uga memory 65,560 0 -65,560
STAT...session pga memory max 262,144 10,551,296 10,289,152
STAT...session uga memory max 261,964 10,592,024 10,330,060
Run1 latches total versus runs -- difference and pct
Run1 Run2 Diff Pct
1,009 1,348 339 74.85%
PL/SQL procedure successfully completed.
SQL>
SQL> conn scott/tiger
Connected.
SQL> set lines 100
SQL> col code for a15
SQL> col code_exp for a15
SQL> col code_regexp for a25
SQL>
SQL> exec runStats_pkg.rs_start;
PL/SQL procedure successfully completed.
SQL> SELECT * FROM codes,code_expressions WHERE regexp_like(code,'^40[0-9]\.[019]1$');
CODE CODE_EXP CODE_REGEXP
402.11 40a.[0,1,9]1 ^40[0-9]\.[019]1$
SQL> exec runStats_pkg.rs_middle;
PL/SQL procedure successfully completed.
SQL> SELECT * FROM codes,code_expressions
2 WHERE regexp_like(code,'^' ||
3 REPLACE (REPLACE (REPLACE (REPLACE (code_exp, 'a', '[0-9]'), '.', '\.'), 'b', '[1-9]'), ',') ||
4 '$');
CODE CODE_EXP CODE_REGEXP
402.11 40a.[0,1,9]1 ^40[0-9]\.[019]1$
SQL> exec runStats_pkg.rs_stop;
Run1 ran in 37 hsecs
Run2 ran in 335 hsecs
run 1 ran in 11.04% of the time
Name Run1 Run2 Diff
STAT...recursive cpu usage 3 2 -1
.... sniped
STAT...CPU used when call star 40 336 296
STAT...CPU used by this sessio 40 336 296
STAT...DB time 40 336 296
STAT...Elapsed Time 39 338 299
STAT...session pga memory 65,536 0 -65,536
STAT...session uga memory 65,560 0 -65,560
STAT...session pga memory max 262,144 10,551,296 10,289,152
STAT...session uga memory max 261,964 10,592,024 10,330,060
Run1 latches total versus runs -- difference and pct
Run1 Run2 Diff Pct
1,022 1,348 326 75.82%
PL/SQL procedure successfully completed.
SQL> explain plan for
2 SELECT * FROM codes,code_expressions WHERE regexp_like(code,'^40[0-9]\.[019]1$');
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 1698472622
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 5000 | 205K| 59 (6)| 00:00:01 |
| 1 | MERGE JOIN CARTESIAN| | 5000 | 205K| 59 (6)| 00:00:01 |
| 2 | TABLE ACCESS FULL | CODE_EXPRESSIONS | 1 | 31 | 3 (0)| 00:00:01 |
| 3 | BUFFER SORT | | 5000 | 55000 | 56 (6)| 00:00:01 |
|* 4 | TABLE ACCESS FULL | CODES | 5000 | 55000 | 56 (6)| 00:00:01 |
Predicate Information (identified by operation id):
4 - filter( REGEXP_LIKE ("CODE",'^40[0-9]\.[019]1$'))
16 rows selected.
SQL> explain plan for
2 SELECT * FROM codes,code_expressions WHERE regexp_like(code,code_regexp);
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 3098457583
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 5000 | 205K| 57 (2)| 00:00:01 |
| 1 | NESTED LOOPS | | 5000 | 205K| 57 (2)| 00:00:01 |
| 2 | TABLE ACCESS FULL| CODE_EXPRESSIONS | 1 | 31 | 3 (0)| 00:00:01 |
|* 3 | TABLE ACCESS FULL| CODES | 5000 | 55000 | 54 (2)| 00:00:01 |
Predicate Information (identified by operation id):
3 - filter( REGEXP_LIKE ("CODE","CODE_REGEXP"))
15 rows selected.
SQL> explain plan for
2 SELECT * FROM codes,code_expressions WHERE regexp_like(code,'^' ||
3 REPLACE (REPLACE (REPLACE (REPLACE (code_exp, 'a', '[0-9]'), '.', '\.'), 'b', '[1-9]'), ',') ||'$');
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 3098457583
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 5000 | 205K| 57 (2)| 00:00:01 |
| 1 | NESTED LOOPS | | 5000 | 205K| 57 (2)| 00:00:01 |
| 2 | TABLE ACCESS FULL| CODE_EXPRESSIONS | 1 | 31 | 3 (0)| 00:00:01 |
|* 3 | TABLE ACCESS FULL| CODES | 5000 | 55000 | 54 (2)| 00:00:01 |
Predicate Information (identified by operation id):
3 - filter( REGEXP_LIKE ("CODE",'^'||REPLACE(REPLACE(REPLACE(REPLACE("CODE_E
XP",'a','[0-9]'),'.','\.'),'b','[1-9]'),',')||'$'))
16 rows selected.Best regards
Maxim -
Code Insight and JSP and JDEVELOPER
Hi everybody
Does anybody can help me how I can enable code insight feature of jdeveloper?
Remember that import statement is in jsp tags.
Thanks a lot
ShahramThe Code Insight feature currently only works with .java files.
null
Maybe you are looking for
-
My ipod touch isn't being registered as a device in itunes
http://ftgmytx
-
Error when starting Designer 10.1.2.3
Hello, The next error appear when i start the designer tool: Reported Message / Cause: ???-21705: The .msb message file for product "Unknown", utility "CDR" could not be found. Action: (blank) i get the message with the username where the repository
-
Dreamweaver cs6 web image gallery
hi to all, i need help with web and image gallery, as far as web is OK but im trying to involve a lot of pictures inside, the problem is im trying to put table inside div tag with auto resize to thumbnails, i hope it is possible o is there another so
-
In the middle of an update, it call closed. Itunes keeps saying that it's not installed, even though ive tried reinstalling multiple times. All my iphone is doing it showing the ituns symbol and a charger. How can I fix this???
-
Conditional Build tags affecting formatting and merging hyperlinks
I'm working in RH6 on a number of projects. In all of them I use a specific caption box/format combination for tips and notes. I also use a conditional build tag so I can generate a 'lite' versions of full help, suitable for printing. I note that on