Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

« Newer Snippets
Older Snippets »
Showing 1-10 of 16 total  RSS 

Linux - command ls without color

// Elimina tutti i caratteri speciali che portano il colore

ls --color=never

Linux - Example Crontab

// Esegue lo script ogni ora

// Minute(0-59) Hours(0-23) DayOfMonth(1-31) Month(1-12) DayOfWeek(0-6/Sun-Sat) Command
* */1 * * * script.sh

Linux - random BG enligthnment

import os
import random

listBG = os.popen('eesh background list').readlines()[:-5]
elemBG = random.choice(listBG)
os.popen('eesh background use ' + elemBG[:-2])

Linux - Escape Terminal

// Scrive sottolineato
echo -e "\033[4m\017Prova"


// Scrive in Blink
echo -e "\033[5m\017Prova"

Linux - IP Duplicate

// Gratuitous ARP

arping -U -I <interface> -s <my_ip> <ip_router>

Linux - XTerm font size

// Aumenta la dimensione del carattere sul terminale

xterm -geometry 640x480 -fn *-fixed-*-*-*-20-*

Bash - avi2mpg

ffmpeg -i video.avi -target vcd video.mpg

Bash - 3gpToMpeg

mencoder video.3gp -o video.mpg -oac pcm -ovc lavc -lavcopts vcodec=mjpeg:mbd=1:vbitrate=1800

Java - Example Very Simple Player (JMF)

// Main Class

package org.jmf.example;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.metal.MetalLookAndFeel;

public class ExampleJMF
{
	public static void main(String[] args)
	{
		JFrame.setDefaultLookAndFeelDecorated(true); 
		JDialog.setDefaultLookAndFeelDecorated(true);
		
		try
		{
			UIManager.setLookAndFeel(new MetalLookAndFeel());
		}
		catch(UnsupportedLookAndFeelException e)
		{
			e.printStackTrace();
		}
		
		new exampleFrame();
	}
}


// Frame Class

package org.jmf.example;

import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;

public class exampleFrame extends JFrame
{
	private static final long serialVersionUID = 1L;
	
	public exampleFrame()
	{
		super("JMF - Example...");
		
		setSize(400, 300);
		setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - getWidth())/2, (Toolkit.getDefaultToolkit().getScreenSize().height - getHeight())/2);
		
		addWindowListener(new WindowAdapter()
		{
			public void windowClosing(WindowEvent evt)
			{
				System.exit(0);
			}
		});
		
		setContentPane(new examplePanel());
		setVisible(true);
	}
}


// Panel Class

package org.jmf.example;

import java.awt.Component;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import javax.media.ControllerEvent;
import javax.media.ControllerListener;
import javax.media.Manager;
import javax.media.NoPlayerException;
import javax.media.Player;
import javax.media.RealizeCompleteEvent;
import javax.swing.JPanel;

public class examplePanel extends JPanel implements ActionListener, ControllerListener
{
	private static final long serialVersionUID = 1L;
	
	private Component visualComponent;
	private Player player;
	
	public examplePanel()
	{
		try
		{
			player = Manager.createPlayer(new URL("file:///tmp/a.mpg"));
			player.addControllerListener(this);
			
			player.start();
		}
		catch(NoPlayerException e)
		{
			e.printStackTrace();
		}
		catch(MalformedURLException e)
		{
			e.printStackTrace();
		}
		catch(IOException e)
		{
			e.printStackTrace();
		}
	}
	
	public void paintComponent(Graphics g)
	{
		super.paintComponent(g);
	}

	public void actionPerformed(ActionEvent e)
	{

	}

	public void controllerUpdate(ControllerEvent c)
	{
		if(player == null)
			return;
		
		if(c instanceof RealizeCompleteEvent)
		{
			if((visualComponent = player.getVisualComponent()) != null)
				add(visualComponent);
		}
	}
}

Bash - Creare una galleria di mini immagini

// Prende le immagini di una cartella e ne crea delle copie
// della dimensione di 320x240

#!/bin/sh

for i in `ls *.jpg`;
do
	convert -geometry 320x240 $i galleria-$i
done
« Newer Snippets
Older Snippets »
Showing 1-10 of 16 total  RSS