Showing posts with label how. Show all posts
Showing posts with label how. Show all posts
Monday, May 29, 2017
Join me along with ISACA and TechTarget today to learn about how to advance your infosec career!
Join me along with ISACA and TechTarget today to learn about how to advance your infosec career!

You can register by clicking the image or via this link:
http://www.bitpipe.com/data/document.do?res_id=1469026420_560
I hope to "see" you there!
Available link for download
Saturday, April 8, 2017
java How do you upload a file to an FTP server
java How do you upload a file to an FTP server
import java.io.File;
import java.io.FileNotFoundException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemOptions;
import org.apache.commons.vfs2.Selectors;
import org.apache.commons.vfs2.impl.StandardFileSystemManager;
import org.apache.commons.vfs2.provider.sftp.SftpFileSystemConfigBuilder;
public void onUpload()
{
String hostName = "xxxxxxx";
String username = "xxxxxxx";
String password = "xxxxxxx";
String ftpfolder = "outbound";
String fileName ="YourLocalFileName";
String remoteFilePath = "/" + ftpfolder + "/" + fileName;
String localFilePath = "YourLocalFilePath";
File file = new File(localFilePath);
if (!file.exists())
throw new RuntimeException("Error. Local file not found");
StandardFileSystemManager manager = new StandardFileSystemManager();
try {
manager.init();
// Create local file object
FileObject localFile = manager.resolveFile(file.getAbsolutePath());
// Create SFTP options
FileSystemOptions opts = new FileSystemOptions();
// SSH Key checking
SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(
opts, "no");
// Root directory set to user home
SftpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts,
false);
// Timeout is count by Milliseconds
SftpFileSystemConfigBuilder.getInstance().setTimeout(opts, 10000);
// Create remote file object
FileObject remoteFile = manager.resolveFile(
createConnectionString(hostName, username, password,
remoteFilePath), opts);
// Copy local file to sftp server
remoteFile.copyFrom(localFile, Selectors.SELECT_SELF);
System.out.println("Done");
} catch (Exception e) {
//Catch and Show the exception
} finally {
manager.close();
win.detach();
}
}
public static String createConnectionString(String hostName,
String username, String password, String remoteFilePath) {
return "sftp://" + username + ":" + password + "@" + hostName + "/"
+ remoteFilePath;
}
Maven artifacts for Apache VFS is a Virtual File System library.
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-vfs2</artifactId>
<version>2.0</version>
</dependency>
Available link for download
Thursday, March 23, 2017
It depends on how you measure it
It depends on how you measure it
I always thought that cooking is simple as long as you have a reliable recipe. Over the years I learned to trust some of the newspaper food columnists, while taking with a grain of salt my kids class cookbooks because some words fade during the kids mail transit and Xeroxing.
Once you have a good recipe there is usually no one to blame for a bad outcome other than yourself. Well, occasionally you can tell that the eggs were too big or the stove is new. My eccentric grandaunt used to prohibit us from entering the kitchen during baking and blame us for disturbing the cakes gestation period if it didnt rise. But there is really not much more. One cup of flour is one cup of flour anywhere in the world, one tablespoon of butter is one tablespoon of butter. Or is it?
This weeks article in the New York Times surprises us by suggesting that it is not. It refers to an experiment when ten different people were asked to scoop 1 cup of flour and pour it into a bowl. The weight of flour in the individual bowls varied between 4 and 6 ounces depending on the strength and technique of scooping used by each participant. This meant that some of these people may be making a cake with 1.5 times as much flour as others.
What else can we use instead of the traditional and universal cup and spoon volume measures? The weight (mass), says the article advocating for simple kitchen scales. Note that weight is equal mass as long as we cook on earth.

Lets recollect some math and physics:
If the mass of 1 cup of flour in the bowls varied from 4 to 6 ounces, it means that the density is to blame. Faster scooping, scooping up vs down techniques, different storage, type of flour, shape of the cup all of them can influence the density of the flour. To get the same amount in your recipe rely on mass.
The difference may be even more drastic when dealing with grated cheese. According to the article the heavier shavings of a box grater can fill a cup with twice as much cheese as billowy ribbons of machine-shaved cheese.
So, get yourself a kitchen scale for the next holidays. Use mass-based recipe source and you will:
What about your old favorite volume-based recipes? One cup of oil in moms sweet corn bread, one cup of honey in the Rosh haShana cake. Should you just convert them to mass? This Pyrex measuring cup clearly marks 1 cup volume as 8 oz mass.

Remember the formula:
For water measurements: 8 oz = 1 cup x Water Density
Oil, melted chocolate and honey are obviously denser than water. Higher density gives higher mass: around 10 oz for one cup of oil, and 12 oz for one cup of honey. So, beware of the Pyrex cup.
It is just you now in the kitchen with your scale and math.
Once you have a good recipe there is usually no one to blame for a bad outcome other than yourself. Well, occasionally you can tell that the eggs were too big or the stove is new. My eccentric grandaunt used to prohibit us from entering the kitchen during baking and blame us for disturbing the cakes gestation period if it didnt rise. But there is really not much more. One cup of flour is one cup of flour anywhere in the world, one tablespoon of butter is one tablespoon of butter. Or is it?
This weeks article in the New York Times surprises us by suggesting that it is not. It refers to an experiment when ten different people were asked to scoop 1 cup of flour and pour it into a bowl. The weight of flour in the individual bowls varied between 4 and 6 ounces depending on the strength and technique of scooping used by each participant. This meant that some of these people may be making a cake with 1.5 times as much flour as others.
What else can we use instead of the traditional and universal cup and spoon volume measures? The weight (mass), says the article advocating for simple kitchen scales. Note that weight is equal mass as long as we cook on earth.

Image by jamieanne, distributed under CCL.
Lets recollect some math and physics:
Mass = Volume x Density
If the mass of 1 cup of flour in the bowls varied from 4 to 6 ounces, it means that the density is to blame. Faster scooping, scooping up vs down techniques, different storage, type of flour, shape of the cup all of them can influence the density of the flour. To get the same amount in your recipe rely on mass.
The difference may be even more drastic when dealing with grated cheese. According to the article the heavier shavings of a box grater can fill a cup with twice as much cheese as billowy ribbons of machine-shaved cheese.
So, get yourself a kitchen scale for the next holidays. Use mass-based recipe source and you will:
- Get consistent recipe-matching results every time.
- Easily double or halve the recipe.
- Have less stuff to clean. You can use only one mixing bowl by slowly adding ingredients into it directly from the containers and zeroing weight on the scale after each addition.
What about your old favorite volume-based recipes? One cup of oil in moms sweet corn bread, one cup of honey in the Rosh haShana cake. Should you just convert them to mass? This Pyrex measuring cup clearly marks 1 cup volume as 8 oz mass.
Mass = Volume x Density
For water measurements: 8 oz = 1 cup x Water Density
Oil, melted chocolate and honey are obviously denser than water. Higher density gives higher mass: around 10 oz for one cup of oil, and 12 oz for one cup of honey. So, beware of the Pyrex cup.
It is just you now in the kitchen with your scale and math.
Amazon links to buy kitchen scale:
Available link for download
Sunday, February 5, 2017
Subscribe to:
Posts (Atom)