A while ago I talked about a possible project I wanted to try based on a site I saw some years ago. And so here it is.
It is a speech profiler which at the moment allows someone to get word counts, sentence counts, and see visually sentence density. In addition, one can search for certain words and phrases to see occurrence density within that visual representation. Finally, one can compare those numbers and visual representations between multiple speeches. I plan to at some point add some additional statistic features such as unique word counts, comparisons, and other things as I think of them or get suggestions. posted by dharh 6:03 PM Mar 18th, 2008
As you can see the Java implementation of Step 1 of 15 Exercises for Learning a new Programming Language was more complicated than the C# implementation. This was largely due to one factor. You can't poll whether someone is typing from the console in Java.
The second problem is that you can't use a KeyEvent handler in the console, which would the second easiest solution to attempt. Finally a third problem is that by using an event handler you essentially need to use threading so that the loop doesn't interfere with the handler and you are able to interrupt properly. If there are better solutions I'd be very interested to see them. package learn2Java1;
import java.awt.BorderLayout;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;
import javax.swing.JTextArea;
public class Program extends JFrame implements KeyListener
{
private JTextArea displayArea;
private static final long serialVersionUID = 1;
public static void main(String[] args)
{
javax.swing.SwingUtilities.invokeLater( new Runnable( ){
public void run( )
{
createAndShowGUI( );
}
});
}
public Program( String name )
{
super( name );
}
private static void createAndShowGUI( )
{
Program frame = new Program( "Press ESC to exit program." );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.addComponentsToPane( );
frame.pack( );
frame.setVisible( true );
Thread t = new Thread( new MessageLoop( frame ) );
t.start( );
}
private void addComponentsToPane( )
{
displayArea = new JTextArea( 0 );
displayArea.setEditable( false );
displayArea.addKeyListener( this );
getContentPane( ).add( displayArea, BorderLayout.CENTER );
}
public void keyPressed(KeyEvent ke) {
checkKey( ke, "KeyPressed: " );
}
public void keyReleased(KeyEvent ke) {
checkKey( ke, "KeyReleased: " );
}
public void keyTyped(KeyEvent ke) {
checkKey( ke, "KeyTyped: " );
}
private void checkKey( KeyEvent ke, String message )
{
System.out.println( message + ke.getKeyCode() );
if ( ke.getID() != KeyEvent.KEY_TYPED && ke.getKeyCode() == KeyEvent.VK_ESCAPE )
System.exit( 0 );
}
public void updateArea( String text )
{
displayArea.setText( text );
}
private static class MessageLoop implements Runnable
{
Program messageSpace;
public MessageLoop( Program thisFrame )
{
messageSpace = thisFrame;
}
public void run( )
{
for ( int i = 0; ; i++ )
{
messageSpace.updateArea( i + " " );
try
{
Thread.sleep( 250 );
} catch ( InterruptedException ie )
{
}
}
}
}
}
posted by dharh 7:15 PM Feb 10th, 2008
1. Display series of numbers (1,2,3,4, 5....etc) in an infinite loop. The program should quit if someone hits a specific key (Say ESCAPE key).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace lrn2CSharp1
{
class Program
{
static void Main( string[ ] args )
{
for ( int i = 0; ; i++ )
{
if ( Console.KeyAvailable && keyPressHandler( Console.ReadKey( true ) ) ) break;
Console.Write( i + " " );
Thread.Sleep( 250 );
}
}
protected static Boolean keyPressHandler( ConsoleKeyInfo input )
{
if ( input.Key == ConsoleKey.Escape ) return true;
return false;
}
}
}
posted by dharh 7:13 PM Feb 10th, 2008
So I saw this page which gives a list of 15 Exercises for Learning a new Programming Language. I thought, this could also be a good way to compare different languages. In that spirit I'm going to do just that and try to complete the list in different popular languages. To start with I will do them in C# and Java.
As it turns out I'm much less familiar with C# than Java so it will also be a learning experience as the original article had intended. You can see the progress in Programming. posted by dharh 6:43 PM Feb 10th, 2008
function trim(str) {
var str = str.replace(/^ss*/, ''),
ws = /s/,
i = str.length;
while (ws.test(str.charAt(--i)));
return str.slice(0, i + 1);
}
source: http://blog.stevenlevithan.com/archives/faster-trim-javascript posted by dharh 1:11 PM Feb 4th, 2008
This guy seems to have the right idea on why people would ever choose open source.
posted by dharh 8:58 PM Jan 27th, 2008
Last Updated 2022-05-13
v2.2.x (12 May 2022) .NET
TODO Todo from prior version is updated or restated as below:
v2.1.322 (14 Feb 2014) ASP.NET
Features
UI
Fixes
Todo
v2.0.134 (19 Mar 2011) New Versioning Skipped 1.0 because the previous cold fusion version for all intents and purposes was 1.0 even though it never made it past the beta stage. I am using an auto versioning system with visual studio. Which means for the most part the third number, the number of compiles, is the main way to tell which version is which. The second number will still keep track of major versions, but I don't really foresee using it much. neTodo.net Released
JQuery
Features
Known Issues
Todo List
v0.2 (14 Aug 2009) Update to JQuery and Preferences Backend JQuery
Preferences
Todo List
v0.1 (26 Jan 2008) Released neTodo Features
posted by dharh 7:43 PM Jan 26th, 2008
« Previous 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Next » |
AI airships america batteries blogs books browser C# c++ chatGPT computers conversation copyright covid cpp cr-48 CSharp dharh disaster DIY DRM economy energy environment FCC gaming google government history HTML humor idt internet interview japan java javascript linkjack linux lrn2program MLP moving music nature nefeedeater neThing neTodo networking news opensource philosophy podcasts poverty programming projects python reading religion science sick simple software space sparce tagging technology twitter unbirthday video wiki
|