How to use JHlabs image filter in spring MVC project

First you have to create image filter class like this

public class ImageFilter {
public void applyFilter(MultipartFile multipartFile){
String destination = “/your/file/destination/folder/”;
try {
GaussianFilter filter = new GaussianFilter();
filter.setRadius(8.5f);
BufferedImage imBuff = ImageIO.read(multipartFile.getInputStream());
filter.filter(imBuff, imBuff);

File outputfile = new File(destination+”image.jpg”);
ImageIO.write(imBuff, “jpg”, outputfile);

} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

And then modify the request mapping method for file upload in your controller like this

@RequestMapping(method = RequestMethod.POST)
public String fileUploaded(Model model, @Validated File file,
BindingResult result) {

String returnVal = “successFile”;
if (result.hasErrors()) {
returnVal = “file”;
} else {
MultipartFile multipartFile = file.getFile();
SaveFileToFolder save = new SaveFileToFolder();
save.saveFile(multipartFile);
}
return returnVal;
}

After running the blurred image will be stored in the location you specified.

How to create a Node.js static page web server

You can use Connect and ServeStatic with Node.js for this:

Install connect and serve-static with NPM

$ npm install connect serve-static

Create server.js file with this content:

var connect = require(‘connect’);
var serveStatic = require(‘serve-static’);
connect().use(serveStatic(__dirname)).listen(8080);

Run with Node.js

$ node server.js

You can now go to http://localhost:8080/yourfile.html

simple HTTP page Server in Node.js

Start by creating a new file named “server.js”. Insert the following code into the file and save it.

var http = require("http");
var server = http.createServer(function(request, response) {
  response.writeHead(200, {"Content-Type": "text/html"});
  response.write("");
  response.write("");
  response.write("");
  response.write("");
  response.write("");
  response.write("");
  response.write("This is my page!");
  response.write("");
  response.write("");
  response.end();
});

server.listen(80);
console.log(“Server is listening”);

To start the server, type the command shown below. If everything works properly, you will see a message that the server is listening. Note that the example server attempts to bind to port 80, the standard HTTP port. If this port is already in use, or is restricted on your machine, you will experience an error.

node server.js

The next step is to connect to the server using a web browser. Launch your browser of choice, and direct it to either of the following links.

http://localhost:80

Simple Node Js web server

Following node.js web server will give “Hello world” to the localhost on the port 8080 no matter what the URL is, giving you an idea what event is.

var sys = require(“sys”),
my_http = require(“http”);
my_http.createServer(function(request,response){
sys.puts(“Called me”);
response.writeHeader(200, {“Content-Type”: “text/plain”});
response.write(“Hello World”);
response.end();
}).listen(8080);
sys.puts(“Server on port 8080″);

Overriding in Swift programming

This article is a continuation from previous article

A subclass can provide its own custom implementation of an instance method, class method, instance property, class property, or subscript that it would otherwise inherit from a superclass. This is known as overriding.
When you provide a method, property, or subscript override for a subclass, it is sometimes useful to use the existing superclass implementation as part of your override. For example, you can refine the behavior of that existing implementation, or store a modified value in an existing inherited variable.

Overriding Methods:

You can override an inherited instance or class method to provide a tailored or alternative implementation of the method within your subclass.

The following example defines a new subclass of Vehicle called Train, which overrides the makeNoise method that Train inherits from Vehicle:

class Train: Vehicle {
    override func makeNoise() {
        println("Choo Choo")
    }
}

If you create a new instance of Train and call its makeNoise method, you can see that the Train subclass version of the method is called:

let train = Train()
train.makeNoise()
// prints "Choo Choo"

Overriding Properties:

You can override an inherited instance or class property to provide your own custom getter and setter for that property, or to add property observers to enable the overriding property to observe when the underlying property value changes.

Overriding Property Observers:

You can use property overriding to add property observers to an inherited property. This enables you to be notified when the value of an inherited property changes, regardless of how that property was originally implemented.

Inheritance in Swift programming language

A class can inherit methods, properties, and other characteristics from another class. When one class inherits from another, the inheriting class is known as a subclass, and the class it inherits from is known as its superclass. Inheritance is a fundamental behavior that differentiates classes from other types in Swift.

Let us check with one example:

The example below defines a base class called Vehicle. This base class defines a stored property called currentSpeed, with a default value of 0.0 (inferring a property type of Double). The currentSpeed property’s value is used by a read-only computed String property called description to create a description of the vehicle.

The Vehicle base class also defines a method called makeNoise. This method does not actually do anything for a base Vehicle instance, but will be customized by subclasses of Vehicle later on:

class Vehicle {
    var currentSpeed = 0.0
    var description: String {
        return "traveling at \(currentSpeed) miles per hour"
    }
    func makeNoise() {
        // do nothing - an arbitrary vehicle doesn't necessarily make a noise
    }
}

////////////Create one object of Vehicle class///////////////
let someVehicle = Vehicle()
rintln(“Vehicle: \(someVehicle.description)”)
// Vehicle: traveling at 0.0 miles per hour

Subclassing is the act of basing a new class on an existing class. The subclass inherits characteristics from the existing class, which you can then refine. You can also add new characteristics to the subclass.

To indicate that a subclass has a superclass, write the subclass name before the superclass name, separated by a colon:

class Bicycle: Vehicle {
var hasBasket = false
}

By default, any new Bicycle instance you create will not have a basket. You can set the hasBasket property to true for a particular Bicycle instance after that instance is created:

let bicycle = Bicycle()
bicycle.hasBasket = true
You can also modify the inherited currentSpeed property of a Bicycle instance, and query the instance’s inherited description property:

bicycle.currentSpeed = 15.0
println(“Bicycle: \(bicycle.description)”)
// Bicycle: traveling at 15.0 miles per hour

Subclasses can themselves be subclassed. The next example creates a subclass of Bicycle for a two-seater bicycle known as a “tandem”:
class Tandem: Bicycle {
var currentNumberOfPassengers = 0
}
Tandem inherits all of the properties and methods from Bicycle, which in turn inherits all of the properties and methods from Vehicle. The Tandem subclass also adds a new stored property called currentNumberOfPassengers, with a default value of 0.

If you create an instance of Tandem, you can work with any of its new and inherited properties, and query the read-only description property it inherits from Vehicle:

let tandem = Tandem()
tandem.hasBasket = true
tandem.currentNumberOfPassengers = 2
tandem.currentSpeed = 22.0
println(“Tandem: \(tandem.description)”)
// Tandem: traveling at 22.0 miles per hour

Closures in Swift programming

Closures are self-contained blocks of functionality that can be passed around and used in your code. Closures in Swift are similar to blocks in C and Objective-C and to lambdas in other programming languages.

Closure expression syntax has the following general form:

{ (parameters) -> return type in
statements
}

The example below shows a closure expression:

let names = [“Chris”, “Alex”, “Ewa”, “Barry”, “Daniella”]
reversed = sorted(names, { (s1: String, s2: String) -> Bool in
return s1 > s2
})

Enumerations in Swift programming language

An enumeration defines a common type for a group of related values and enables you to work with those values in a type-safe way within your code.

Enumeration Syntax:

enum SomeEnumeration {
// enumeration definition goes here
}

Here’s an example for the four main points of a compass:

enum CompassPoint {
case North
case South
case East
case West
}

You can match individual enumeration values with a switch statement:

directionToHead = .South
switch directionToHead {
case .North:
println(“Lots of planets have a north”)
case .South:
println(“Watch out for penguins”)
case .East:
println(“Where the sun rises”)
case .West:
println(“Where the skies are blue”)
}

Sharks Cove mini PC from Microsoft, competitor for Raspberry Pi

sharkscoveh-640x353

Though it takes Microsoft a while to jump in on an emerging trend, the company does tend to throw its hat into the ring eventually. Despite releasing satisfactory hardware, the company was late to both the modern-day smartphone and tablet scene, hindering its success. This time around — likely thanks to the success of the Raspberry Pi — Microsoft is targeting the mini PC and development board market with the release of Sharks Cove.

Read More..

3D printer from the Arduino firm

arduino3d

Arduino is best known for its micro-controller of the same name and we’ve covered countless projects featuring the little electronic wonder over the years. With the 3D casino online printing industry making massive inroads in the do-it-yourself market, it’s not that surprising that the company behind one of the ultimate bits of hobbyist gear is releasing its own 3D printer.

Read More..