Squid set download limit and prevent downloads by extension

200px-Squid-cache_logo

 

 

 

 

 

Open squid.conf file

sudo vim /etc /squid3/squid.conf

search for reply_body_max_size you can see a line like this

reply_body_max_size 10 MB it will limit the download by 10 MB.

This option specifies the maximum size of a reply body. It can be  used to prevent users from downloading very large files, such as MP3’s and movies.

To prevent download of a particular file type you can use regular expressions

acl mp3_ext url_regex -i \.mp3$

This acl is to prevent mp3 downloads.The http_acces for this acl is

http_access deny mp3_ext

To prevent youtube streaming

acl flash rep_mime_type video/x-flv

and the http_acces

http_reply_access deny flash

We can group different types and write it in a file and can be asked to block

acl denied_filetype url_regex "/etc/squid3/denied_filetype"

Now the types written in the file denied_filetype will be blocked with the below http_access

http_access deny denied_filetype

 

Proocessing to Arduino commnication

The following code describes how processing to arduino serial communication can be done…processing to arduino communication is very helpful when kinect is used along with processing..

Processing code

import processing.serial.*;
Serial port;

void setup() {
size(256, 150);

println("Available serial ports:");
println(Serial.list());

port = new Serial(this, Serial.list()[0], 9600);

}

void draw() {
// draw a gradient from black to white
for (int i = 0; i < 256; i++) {
stroke(i);
line(i, 0, i, 150);
}

// write the current X-position of the mouse to the serial port as
// a single byte
port.write(mouseX);
}

Serial.list()[0] uses the first port in this list (number 0) and aud used is 9600 if you know the port you can give it directly..

Arduino code

const int ledPin = 12;

void setup()
{

Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}

void loop() {
byte brightness;

if (Serial.available()) {

brightness = Serial.read();
if(brightness > 100){

digitalWrite(ledPin,HIGH);
}
else{
digitalWrite(ledPin,LOW);
}
}
}

First upload the arduino code connect an led to pin no 12 then run the processing code a window will open with black and white gradient..if you move the cursor to white or above 100 then the led becomes high..

Happy Hacking 🙂

Configuring Kinect with processing in ubuntu

Xbox-360-Kinect-Standalone

To configure kinect with processing in ubuntu 12.04..first download openni installer

wget http://simple-openni.googlecode.com/files/OpenNI_NITE_Installer-Linux32-0.27.zip

uncompress the file…there will be four folders like this.

Screenshot from 2013-01-18 16:55:03

Inside kinect folder there will be one more folder named Sensor-Bin-Linux…all folders will be having an install.sh file

open a terminal and cd to each folder and issue the following install command

sudo ./install.sh

Now download processing software i used the stable release processing 1.5

wget http://processing.googlecode.com/files/processing-1.5.1-linux.tgz

extract it

Now download SimpleOpenNI processing library

wget http://simple-openni.googlecode.com/files/SimpleOpenNI-0.27.zip

when you run processing for the first time a folder named sketchbook will be created inside home folder

Copy the ‘SimpleOpenNI.zip’ into this folder:

~/sketchbook/libraries

and extract it

if you don’t have libraries folder then create one inside sketchbook

Now restart porcessing from file menu take Examples>Contributed Libraries>simple openni and select depth image example.

Screenshot from 2013-01-17 03_51_51

Connect the kinect to the system .Now compile and run the code if sucessfulyou will get an output window like this.

Screenshot from 2013-01-17 03_53_50

You need java installed in yur system for the working of processing

Happy Hacking 🙂