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-9 of 9 total  RSS 

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

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

Xlib - mouseClick

// Simula il click del mouse

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <unistd.h>

#include <X11/Xlib.h>
#include <X11/Xutil.h>

void mouseClick(int button)
{
	Display *display = XOpenDisplay(NULL);

	XEvent event;
	
	if(display == NULL)
	{
		fprintf(stderr, "Errore nell'apertura del Display !!!\n");
		exit(EXIT_FAILURE);
	}
	
	memset(&event, 0x00, sizeof(event));
	
	event.type = ButtonPress;
	event.xbutton.button = button;
	event.xbutton.same_screen = True;
	
	XQueryPointer(display, RootWindow(display, DefaultScreen(display)), &event.xbutton.root, &event.xbutton.window, &event.xbutton.x_root, &event.xbutton.y_root, &event.xbutton.x, &event.xbutton.y, &event.xbutton.state);
	
	event.xbutton.subwindow = event.xbutton.window;
	
	while(event.xbutton.subwindow)
	{
		event.xbutton.window = event.xbutton.subwindow;
		
		XQueryPointer(display, event.xbutton.window, &event.xbutton.root, &event.xbutton.subwindow, &event.xbutton.x_root, &event.xbutton.y_root, &event.xbutton.x, &event.xbutton.y, &event.xbutton.state);
	}
	
	if(XSendEvent(display, PointerWindow, True, 0xfff, &event) == 0) fprintf(stderr, "Errore nell'invio dell'evento !!!\n");
	
	XFlush(display);
	
	usleep(100000);
	
	event.type = ButtonRelease;
	event.xbutton.state = 0x100;
	
	if(XSendEvent(display, PointerWindow, True, 0xfff, &event) == 0) fprintf(stderr, "Errore nell'invio dell'evento !!!\n");
	
	XFlush(display);
	
	XCloseDisplay(display);
}


// gcc source.c -L /usr/X11R6/lib -lX11

Xlib - mouseMove

// muove il mouse alle coordinate currentX + x, currentY + y

#include <stdio.h>
#include <stdlib.h>

#include <X11/Xlib.h>
#include <X11/Xutil.h>

void mouseMove(int x, int y)
{
	Display *displayMain = XOpenDisplay(NULL);

	if(displayMain == NULL)
	{
		fprintf(stderr, "Errore nell'apertura del Display !!!\n");
		exit(EXIT_FAILURE);
	}

	XWarpPointer(displayMain, None, None, 0, 0, 0, 0, x, y);

	XCloseDisplay(displayMain);
}


// gcc source.c -L /usr/X11R6/lib -lX11
« Newer Snippets
Older Snippets »
Showing 1-9 of 9 total  RSS