Programming

Love Ruby on Rails? Love teaching? Like blogging? Want to help contribute back to the Rails community? Look no farther friends, you can do so here!  Email me or comment on this post if you’re interested in contributing links, news,...
Love Ruby on Rails? Love teaching? Like blogging? Want to help contribute back to the Rails community? Look no farther friends, you can do so here!  Email me or comment on this post if you’re interested in contributing links, news, and information to the community.
13 minutes ago
Chances are you might have needed to convert a list of strings or numbers to a CSV file while you were programming something. An example is that in any java program you might have obtained a list of states of United States stored in your...
Chances are you might have needed to convert a list of strings or numbers to a CSV file while you were programming something. An example is that in any java program you might have obtained a list of states of United States stored in your ArrayList object and then you wanted to have them in a CSV format so that you probably could load it to a database or use it for some other purposes. I wrote this tool to serve the same purpose. Here are the basic features this simple java example can do. Given a list of String objects stored in an ArrayList, this program can: Convert Strings or numbers stored in an ArrayList object to comma separated strings Print the comma separated values (CSV) to either console or file Optionally you can sort the the list before you do the conversion. package com.kushal.tools; import java.io.BufferedWriter; import java.io.FileWriter; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; /** * @author Kushal Paudyal * Last Modified on 2011-09-06 This utility converts a * list to comma separated values. Intended to be used with Strings and * can be modified with numbers. * * Have options to write the converted values to either console or file. */ public class ListToCSV { private static boolean writeCSVToConsole = true; private static boolean writeCSVToFile = true; private static String destinationCSVFile = "C:\\temp\\convertedCSV.csv"; private static boolean sortTheList = true; public static void main(String[] args) { ListToCSV util = new ListToCSV(); List sampleList = util.createSampleList(); util.convertAndPrint(sampleList, writeCSVToConsole, writeCSVToFile, sortTheList); } /** * @param sampleList - input list of string * @param writeToConsole - if this flag is true, writes to console * @param writeToFile - if this flag is true writes to file. * @param sortTheList - if the list is to be sorted before conversion */ private void convertAndPrint(List sampleList, boolean writeToConsole, boolean writeToFile, boolean sortTheList) { String commaSeparatedValues = ""; /** If the list is not null and the list size is not zero, do the processing**/ if (sampleList != null) { /** Sort the list if sortTheList was passed as true**/ if(sortTheList) { Collections.sort(sampleList); } /**Iterate through the list and append comma after each values**/ Iterator iter = sampleList.iterator(); while (iter.hasNext()) { commaSeparatedValues += iter.next() + ","; } /**Remove the last comma**/ if (commaSeparatedValues.endsWith(",")) { commaSeparatedValues = commaSeparatedValues.substring(0, commaSeparatedValues.lastIndexOf(",")); } } /** If writeToConsole flag was passed as true, output to console**/ if(writeToConsole) { System.out.println(commaSeparatedValues); } /** If writeToFile flag was passed as true, output to File**/ if(writeToFile) { try { FileWriter fstream = new FileWriter(destinationCSVFile, false); BufferedWriter out = new BufferedWriter(fstream); out.write(commaSeparatedValues); out.close(); System.out.println("*** Also wrote this information to file: " + destinationCSVFile); } catch (Exception e) { e.printStackTrace(); } } } /** * Creates a sample list to be used by the convertAndPrint method * and returns it to the calling method. */ private List createSampleList() { List sampleList = new ArrayList(); sampleList.add("Nebraska"); sampleList.add("Iowa"); sampleList.add("Illinois"); sampleList.add("Idaho"); return sampleList; } } Originally posted 2011-09-16 18:54:06.
17 minutes ago
As we announced earlier this month at the annual Adobe Max Conference, DMXzone has been working on extension that provides complete support for Twitter Bootstrap in Dreamweaver. With the DMXzone Bootstrap you'll have a crafty tool in you...
As we announced earlier this month at the annual Adobe Max Conference, DMXzone has been working on extension that provides complete support for Twitter Bootstrap in Dreamweaver. With the DMXzone Bootstrap you'll have a crafty tool in your hands to edit your layouts fully visual in DW design view and experience the great bootstrap power with its responsive grid. This and many more comes on DMXzone next week so stay tuned.
about 1 hour ago
Free-to-play MMO developer and publisher Wargaming (World of Tanks, World of Warplanes, and World of Warships) has announced that it will provide financial support for three open-source foundations. The company says that it is doing this...
Free-to-play MMO developer and publisher Wargaming (World of Tanks, World of Warplanes, and World of Warships) has announced that it will provide financial support for three open-source foundations. The company says that it is doing this because it uses a number of open-source technologies in its games and it wants to help support those technologies grow and prosper.read more
about 1 hour ago
Hello guys, I'd like to auto populate my app recently converted to south, with permission group and user data. However, after generating a fixture and calling it from the datamigration I'm getting this error. I've put the ...
Hello guys, I'd like to auto populate my app recently converted to south, with permission group and user data. However, after generating a fixture and calling it from the datamigration I'm getting this error. I've put the steps I'm taking detailed here [link]
about 1 hour ago
I’ve done this rant live to various people, but I thought it was time to write it down. First of all: I like Unity3D. I sincerely think Unity3D existing makes the games industry a better place. But, basically, I don’t see how...
I’ve done this rant live to various people, but I thought it was time to write it down. First of all: I like Unity3D. I sincerely think Unity3D existing makes the games industry a better place. But, basically, I don’t see how it can be used for efficient, professional game development, with teams of 6 people or more all actually using Unity. I’m sure people are doing this, but I’d like to know how. This rant is based on my experiences on a project that used Unity 3.5. Maybe Unity 4 is better. It was our first Unity3D project, but to be honest we spoke to a lot of other Unity developers and if there were any major rookie mistakes we made I don’t know what they are. Final caveat: It’s been a while since I’ve gotten my hands dirty on this, plus I wasn’t the one who set up the project, so I might get some details wrong. We used Unity3D with Perforce, with a team of 6 to 8 people, most of whom had to work within Unity itself, as opposed to just making bitmaps or something. The daily workflow for pretty much everyone on the team was: Check out everything in the Unity folder in Perforce. Not ‘get latest’. Check out. Open Unity3D. Do your work and test it. Save, then quit Unity3D. You must do this. Go into Perforce, reverse unchanged files, then try and guess if any files, particularly all of those tiny .meta files, have been added or removed and tell Perforce about those. Repeat. Unless you want to change a scene, then you must yell through the office that you’re going to change a scene, lock the scene file, then do all of the above. So this was pretty much like not having a repository. We had things set up so scenes and other data are text files, but to be honest, just because it’s now YAML doesn’t mean you can just merge scenes – all those internal references don’t necessarily match up. That’s a pretty sucky workflow, and it took us a while to get it through everyone’s heads that they really, really had to do all this. I personally suspect – I never investigated this – that we had to quit Unity because of one plugin that saves important files on exit. But to be honest if that’s the case I still see that as a design flaw in Unity. So, internet: what did we do wrong? What are your experiences with Unity3D and teams of more than a couple of people? We did not use the Team License – could that have solved our problems, and if so how?
about 1 hour ago
Q) What are the project templates presented to you by Visual Studio when you start a ASP.NET MVC 4 Project? Empty - empty ASP.NET MVC 4 Project Basic - basic ASP.NET MVC 4 Project Internet Application - a default ASP.NET MVC 4 Pro...
Q) What are the project templates presented to you by Visual Studio when you start a ASP.NET MVC 4 Project? Empty - empty ASP.NET MVC 4 Project Basic - basic ASP.NET MVC 4 Project Internet Application - a default ASP.NET MVC 4 Project with an account controller that uses Forms Authentication Intranet Application - a default ASP.NET MVC 4 Project with an account controller that uses Windows Authentication Mobile Application - an ASP.NET MVC 4 Project for mobile devices with an account controller that uses Forms Authentication Web API - a ASP.NET Web API Projects Q) What is the name of the unit testing Framework that is available with a ASP.NET MVC 4 Project in Visual Studio? MSTest Q) Which code will execute before any of the Controllers are run? The code within Application_Start() in global.asax will start executing before any of the Controllers run Q) Which HTTP status code does a RedirectPermanent ActionResult return? RedirectPermanent returns a 301 status code Q) How does ASP.NET know how to deliver a request like http://localhost/home/about? Routing engine (not tied to ASP.NET MVC Framework) directs requests to Controllers. The route map is defined in global.asax Q) What is NuGet? It is a Package Manager for .NET applications. NuGet can be used to install, update and configure software (DLLs) in the form of Packages, for use in a Visual Studio project. This way you don't have to download it or track dependencies. NuGet understands package dependencies & will fetch dependent packages as well. Q) Where do NuGet Packages come from? NuGet official feed of packages (from nuget.org) Your local repository Your network share Q) Where do NuGet Packages go? When you install a NuGet package it goes into the Packages folder within the Visual Studio Solution from where you requested. It stores the Package on a per solution basis, not putting in the GAC or Program Files. It is local to that Solution. This makes it easy to update and put a package under version control. The Packages.config file within a Visual Studio solution lists all the Packages that have been installed for the project Q) What is in a NuGet Package? A *.nupkg is a zip file that contains: Metadata - dependencies, URLs, version numbers are specified in a XML file Binaries - assemblies (DLLs) Other content - scripts, images, code blocks Q) Can NuGet commands be executed from the command line? Yes, using PowerShell. To view the list of commands, open the Package Manager Console in Visual Studio (View > Other Windows > Package Manager Console) & type help package Q) Which is the namespace you have to include when you're using DataAnnotations? System.ComponentModel.DataAnnotations Q) Where does the Layout view reside? The Layout view in Razor (the equivalent of Master Page in ASP.NET WebForms) resides in the Shared folder under the Views folder. It is represented by the _Layout.cshtml file Q) How does MVC runtime know that it has to use _Layout.cshtml? Q) What is the significance of the _ViewStart.cshtml file? _ViewStart.cshtml resides in the root of the Views folder. It contains a code block containing a Layout property set to the the _Layout.cshtml file. It is a Razor convention that anything inside _ViewStart.cshtml will execute before a View does. _ViewStart.cshtml applies to all Views. It can be overriden on a per View basis. Q) How to ignore the default Layout view? To avoid using the default Layout page, set Layout property to null Q) Can you build your own custom HTML Helpers? Yes, you can build your custom HTML Helpers work in progress... Tech Tips, Tricks & Trivia - A seasoned developer's little discoveries and annotated bookmarks.
about 2 hours ago
Mark your agenda for this year's most focused event for Oracle EMEA CRM&CX partners! The next CRM&CX Partner Community Forum will take place in the very of center of Paris on July 2&3. During this 2 days (free of charge) event, you w...
Mark your agenda for this year's most focused event for Oracle EMEA CRM&CX partners! The next CRM&CX Partner Community Forum will take place in the very of center of Paris on July 2&3. During this 2 days (free of charge) event, you will have an unique opportunity to: Be among the first to learn... [Read More]
about 2 hours ago
In addition to launching its new generation Kinect alongside the Xbox One, Microsoft also plans to again release a version of the powerful sensor that's geared for Windows. A post on the company's Kinect blog today confirms the product w...
In addition to launching its new generation Kinect alongside the Xbox One, Microsoft also plans to again release a version of the powerful sensor that's geared for Windows. A post on the company's Kinect blog today confirms the product will be released next year, meaning it will trail behind its console counterpart. Both versions of the new Kinect have been built on top of a shared foundation of technologies, however. When the hardware eventually does reach the hands of developers, Microsoft promises it will "revolutionize computing experiences" thanks to higher fidelity, an expanded field of view, improved skeletal tracking, and other improvements. We were impressed with the latest Kinect during our brief trial at Microsoft's Xbox One... Continue reading…
about 2 hours ago
As a web designer, you have a variety of tools and resources that you can choose from to make your work easier and/or better, but picking the ones that are the best for your needs might be a little bit difficult if you are not up-to-date.
As a web designer, you have a variety of tools and resources that you can choose from to make your work easier and/or better, but picking the ones that are the best for your needs might be a little bit difficult if you are not up-to-date.
about 2 hours ago