%~dp$PATH:1FOO.pl %*
Tag Archive for windows
.bat file that calls a script and passes arguments to the script
Category: Uncategorized |
Tags: bat, batch, batchfile, environment, name, os, parameters, path, scripting, windows, wrapper
How to start CPAN on Windows/ActivePerl
perl -MCPAN -e shell
IRB clear screen on windows
# throw this inside %userprofile%.irbrc and you're good
def cls
system('cls')
end
Restoring the Quick Launch toolbar
Trigger notepad and copy paste the following: [Shell] Command=2 IconFile=explorer.exe,3 [Taskbar] Command=ToggleDesktop Save the file as "ShowDesktop.scf" under C:Documents and Settings<USERNAME>Application DataMicrosoftInternet ExplorerQuick Launch
Category: Uncategorized |
Tags: windows
Basic Multithreaded Code
private void button3_Click(object sender, System.EventArgs e)
{
ThreadStart ts = new ThreadStart(HelloFromThread);
Thread t = new Thread(ts);
t.Start();
}
private void HelloFromThread()
{
button3.Text = "Hello From Thread";
}
Display a ToolTip for a DataGrid Cell
private void dataGrid1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
try
{
DataGrid.HitTestInfo hti = dataGrid1.HitTest(e.X,e.Y);
if(hti.Type == DataGrid.HitTestType.Cell)
{
toolTip1.SetToolTip(dataGrid1, dataGrid1[hti.Row, hti.Column].ToString());
}
}
catch{}
}
Workaround to remove or rename files with long names
REM map a temporary directory to the current path subst T: . T: REM rename the file rename "a-very-long-(over-200-characters-here)-name.doc" shortname.doc REM or remove it del "a-very-long-(over-200-characters-here)-name.doc" REM then detach the temp. drive C: subst T: /d
C++ – Hello World
/*
*
* Semplice esempio di Hello World !!!
*/
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
cout << "Hello World !!!" << endl; // endl equivale ad un
return 0;
}
Java – Mini Lettore Wav
package Multimedia;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.metal.MetalLookAndFeel;
public class AudioSystem
{
public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
try
{
UIManager.setLookAndFeel(new MetalLookAndFeel());
}
catch(UnsupportedLookAndFeelException e)
{
e.printStackTrace();
}
new AudioGUI();
}
}
package Multimedia;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.File;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class AudioGUI extends JFrame implements WindowListener
{
public AudioGUI()
{
this.setTitle("AudioSystem");
this.setSize(240, 100);
this.setResizable(false);
this.addWindowListener(this);
Container gc = this.getContentPane();
gc.add(new AudioGUIPan());
this.setVisible(true);
}
public void windowOpened(WindowEvent e)
{
}
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
public void windowClosed(WindowEvent e)
{
}
public void windowIconified(WindowEvent e)
{
}
public void windowDeiconified(WindowEvent e)
{
}
public void windowActivated(WindowEvent e)
{
}
public void windowDeactivated(WindowEvent e)
{
}
}
class AudioGUIPan extends JPanel implements ActionListener
{
private JButton play;
private JButton stop;
private JButton loop;
private JButton open;
private JButton close;
private JFileChooser jfc;
private String file;
private AudioDevice ad;
public AudioGUIPan()
{
play = new JButton("Play");
play.addActionListener(this);
stop = new JButton("Stop");
stop.addActionListener(this);
open = new JButton("Open");
open.addActionListener(this);
close = new JButton("Close");
close.addActionListener(this);
this.add(stop);
this.add(play);
this.add(open);
this.add(close);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == close)
{
System.exit(0);
}
else if(e.getSource() == open)
{
jfc = new JFileChooser();
jfc.setFileFilter(new AudioFilter());
if(jfc.showOpenDialog(this) != JFileChooser.CANCEL_OPTION)
{
file = jfc.getSelectedFile().getAbsolutePath();
ad = new AudioDevice(new File(file));
}
}
else if(e.getSource() == play)
{
if(ad != null)
ad.play();
}
else if(e.getSource() == stop)
{
if(ad != null)
ad.stop();
}
}
}
package Multimedia;
import java.io.File;
import javax.swing.filechooser.FileFilter;
public class AudioFilter extends FileFilter
{
public boolean accept(File f)
{
return f.getName().toLowerCase().endsWith(".wav") || f.isDirectory();
}
public String getDescription()
{
return "Audio File *.wav";
}
}
package Multimedia;
import java.applet.Applet;
import java.applet.AudioClip;
import java.io.File;
import java.net.MalformedURLException;
public class AudioDevice implements AudioClip
{
private AudioClip ac;
public AudioDevice(File f)
{
try
{
ac = Applet.newAudioClip(f.toURL());
}
catch(MalformedURLException e)
{
e.printStackTrace();
}
}
public void play()
{
ac.play();
}
public void stop()
{
ac.stop();
}
public void loop()
{
}
}
C – clear screen
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
// Funziona sui terminali compatibili ansi
fprintf(stdout, " 33[2J"); // Cancella lo schermo
fprintf(stdout, " 33[1;1H"); // Posiziona il cursore sulla linea colonna 1
return EXIT_SUCCESS;
}