randomscameacross-blog
randomscameacross-blog
Randoms Came Across
61 posts
Things I found here and there
Don't wanna be here? Send us removal request.
randomscameacross-blog · 9 years ago
Link
Adding Existing Project to Github or Bitbucket repository using the Git Bash
0 notes
randomscameacross-blog · 9 years ago
Link
Still I refer this blog post when I want to set up git with Bitbucket and TortoiseGit. Thanks for the awesome step-by-step tutorial Guhan.
0 notes
randomscameacross-blog · 9 years ago
Link
How to mark your trip on Google Maps
0 notes
randomscameacross-blog · 10 years ago
Text
How to compress a folder using 7zip in C#
Here fileDirPath is the path to my folder which has all my files and preferredPath is the path where I want my .zip file to be.
eg: var fileDirePath = @"C:\Temp"; var prefferedPath = @"C:\Output\results.zip";
private void CreateZipFile(string fileDirPath, string prefferedPath) { ProcessStartInfo p = new ProcessStartInfo(); p.FileName = @"C:\Program Files\7-Zip\7z.exe"; p.Arguments = "a \"" + prefferedPath + "\" \"" + fileDirPath + "\""; p.WindowStyle = ProcessWindowStyle.Hidden; Process x = Process.Start(p); x.WaitForExit(); return; }
0 notes
randomscameacross-blog · 10 years ago
Text
My Year in Books
https://www.goodreads.com/user/year_in_books/2015/
0 notes
randomscameacross-blog · 10 years ago
Text
Example for Delegate in C#
namespace testobserver { public delegate void ChangeRelationshipStatusDelegate(string status); public class Boy { public string relationshipStatus { get; set; } public void Propose(ChangeRelationshipStatusDelegate relationshipStatusChange) { relationshipStatusChange("enaged"); } } }
namespace testobserver { public class Girl { public string relationshipStatus { get; set; } public void ChangeStatus(string status) { relationshipStatus = status; } } }
using System; namespace testobserver { class Program { static void Main(string[] args) { Girl kim = new Girl(); kim.relationshipStatus = "single"; Console.WriteLine("before propose: " + kim.relationshipStatus); Boy kanye = new Boy(); kanye.Propose(new ChangeRelationshipStatusDelegate(kim.ChangeStatus)); Console.WriteLine("proposal notified to Girl and proposal accepted: " + kim.relationshipStatus); Console.ReadLine(); } } }
0 notes
randomscameacross-blog · 10 years ago
Text
How to list directory content of an FTP server
private string[] GetAnnouncementFileNames(string ftpFolderPath, string ftpUsername, string ftpPassword) { FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpFolderPath); request.Method = WebRequestMethods.Ftp.ListDirectory; request.Credentials = new NetworkCredential(ftpUsername, ftpPassword); using (FtpWebResponse response = (FtpWebResponse)request.GetResponse()) { using (Stream responseStream = response.GetResponseStream()) { using (StreamReader reader = new StreamReader(responseStream)) { var fileNameString = reader.ReadToEnd(); var fileNames = fileNameString.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); return fileNames; } } } }
0 notes
randomscameacross-blog · 10 years ago
Text
My Takeaway from Cloud Asia 2015
0 notes
randomscameacross-blog · 10 years ago
Text
How to call a MATLAB Function from C#
Say you have a MATLAB function called “myfunction” as follows
function [x] = myfunc(a,b) x = a + b; end
Save this function in a file called “myfunction.m” at “c:\temp\example”. 
Create a C# Console Application and add a reference to “Matlab Application (version x.x) Type Library” COM object.
Copy and paste the following code to your Main method.
using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication {    class Program    {        static void Main(string[] args)        {            // Create the MATLAB instance            MLApp.MLApp matlab = new MLApp.MLApp();            // Change to the directory where the function is located            matlab.Execute(@"cd c:\temp\example");            // Define the output            object result = null;            // Call the MATLAB function myfunc            matlab.Feval("myfunc", 1, out result, 2, 3 );                        // Display result            object[] res = result as object[];                        Console.WriteLine(res[0]);            Console.ReadLine();        }    } }
In the code Feval function evaluate your function. I have provide the arguments; function name, number of output parameters, return result, first input parameter, second input parameter for my MATLAB function. You can pass all your parameters here.
Now you should be able to run the program and see “5” printed on the console.
References:
http://www.mathworks.com/help/matlab/matlab_external/call-matlab-function-from-c-client.html
0 notes
randomscameacross-blog · 10 years ago
Text
Book Review: The Software Craftsman by Sandro Mancuso
The Software Craftsman: Professionalism, Pragmatism, Pride by Sandro Mancuso is a must read book by all the software developers. It probably contains everything you need to know. If I summarize my take away from this book, the author suggests us to blog, read books, follow technical websites, use social media and know who to follow, practice programming everyday by trying Katas, having pet projects, contributing to open source, take part in user group and community activities and more pair programming. He also highlights the values of TDD, use of continuous integration. He tells the readers to think about career development one job at a time. He suggests to select a job where we have autonomy. The job criteria should matches to our purpose and leads us to mastery. We can take the decision to terminate the job when any of them (autonomy, mastery and purpose) are deviated from our expectation. He also explains the cost of employing 9-5 developers in team and the value, a passionate developer can bring to a company and to other fellow developers. Further he highlights that being passionate about your job will take you to your ultimate goal, to become a software craftsman.
Tumblr media
photo credits: www.amazon.com
You can find my book review at https://www.goodreads.com/review/show/1376362402
1 note · View note
randomscameacross-blog · 10 years ago
Text
Upgraded to Windows 10
I know I am late to the party, but I received Windows 10 upgrade yesterday. Some of my friends gave me bad reviews about direct upgrading. But I thought of trying it out anyway.
Tumblr media
After around an hour it was upgraded and there is no issues I found yet with my Dell Inspiron 15. I must say I am in love with the new user experience so far.
Tumblr media
But my husband came across an issue in his Asus laptop’s touch pad. After searching through the forums we found out that it is quite common in that range. His touchpad device drivers were disabled. Anyway it can be enabled manually and according to Asus Singapore customer support there is no patch for that yet. 
0 notes
randomscameacross-blog · 10 years ago
Photo
Tumblr media
“The Software Craftsman - Professionalism, Pragmatism, Pride” by Sandro Mancuso 
0 notes
randomscameacross-blog · 10 years ago
Text
Visualize Your Geo Data with ArcGIS Tools
Yesterday I got the opportunity to attend the talk “Using API’s to Geo-enable your location data” conducted by Ms. Anjusha Sandeep, Chief Technology Strategist at ESRI which was held at National Library Building at Bugis, Singapore. As a person who is new to Geo data I found this talk very interesting. In the talk she basically demonstrated the tools and technologies ESRI has built to visualize and analyze data easily. 
According to the speaker most of the data has a location component of it and it is too valuable to miss out. These location component can be used to visualize data on maps and provide answers to many questions. As an example if we can draw the locations of dengue patients of 2015 on a map, then we can decide which area has affected by dengue the most and can find out the reasons for spreading dengue accordingly. 
ESRI are the people who built ArcGIS. ArcGIS is a geographic information system (GIS) for working with maps and geographic information.  It is used for: creating and using maps; compiling geographic data; analyzing mapped information; sharing and discovering geographic information; using maps and geographic information in a range of applications; and managing geographic information in a database. 
They can help you to do lot of cool stuff. According to the presentation you can just drag and drop your data file into their map and do few configurations and you can have an interactive smart map, you can further configure it to convey your story to your audience. You can publish your map as a presentation, a web app or in few other formats and do your customization either by using one of their ready-made widgets or you can code it to collaborate with other applications. The coolest thing I found in the demonstration is publishing your map in a native mobile app. You can do it at http://appstudio.arcgis.com/ .  
According to them most of their projects are available in github at https://github.com/Esri and you can fork and extend it for your usage. Hope this article on ArcGIS tools from yesterdays talk will help you when you come across a problem to visualize Geo data. 
3 notes · View notes
randomscameacross-blog · 10 years ago
Text
Visual C# Code Snippets
What is a code snippet?
Code snippet is a ready made few lines of code, which is ready to insert into your code. Say you want to add a property to your class in C#. Type prop and press tab key twice, you will have a property inserted in your class which is waiting to be modified according to your requirement.
C# code snippets make day to day life of a C# programmer is very easy.
How to use code snippets?
Here is the link to default code snippets supported in Visual Studio: https://msdn.microsoft.com/en-us/library/z41h7fat.aspx
How to create a code snippet?
Steps to create your own method snippet is as follows.
1. Create a new text file and name it as method.snippet
2. Copy and paste the following code in to the method.snippet file.
<?xml version="1.0" encoding="utf-8" ?> <CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">    <CodeSnippet Format="1.0.0">        <Header>            <Title>method</Title>            <Shortcut>method</Shortcut>            <Description>Code snippet for method</Description>                      <SnippetTypes>                <SnippetType>Expansion</SnippetType>            </SnippetTypes>        </Header>        <Snippet>            <Declarations>                <Literal>                    <ID>methodname</ID>                    <ToolTip>Method name</ToolTip>                    <Function>MethodName()</Function>                    <Default>MethodNamePlaceholder</Default>                </Literal>            </Declarations>            <Code Language="csharp"><![CDATA[public void $methodname$ ()    {        $end$    }]]>            </Code>        </Snippet>    </CodeSnippet> </CodeSnippets>
3. Copy your file into visual studio’s snippet folder.
 My snippets folder located at : C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC#\Snippets\1033\Visual C#
4. Restart visual studio if you have already running it.
5. Open visual studio C# class and type method and press tab key twice.
6. You will see a method created as follows
public void MethodNamePlaceholder()    {    }
7. Go ahead and change your method as you want.
Credits:
 http://stackoverflow.com/a/19247785/778101
https://msdn.microsoft.com/en-us/library/ms165394.aspx
have fun with code snippets!
0 notes
randomscameacross-blog · 10 years ago
Text
Dress up your javascript alerts
I found the javascript library SweetAlert to make the boring javascript alerts beautiful. You can download the library from http://t4t5.github.io/sweetalert/ and add reference to the sweetalert.min.js and sweetalert.css files in your master html page. My sweetalert files are located at sweetalert folder in the library folder of my project. So I can refer it as below.
<link rel="stylesheet" href="library/sweetalert/sweetalert.css"/>
<script src="library/sweetalert/sweetalert.min.js"></script>
Then you can create an alert as in their examples very easily.
 Have fun creating sweet alerts!
0 notes
randomscameacross-blog · 10 years ago
Text
Visualize data on your map
If you are using leaflet.js to show a map in your web page, you can easily use geoserver to host your data files (ex: .shp files) and retrieved them in PNG format and layer on top of your map. Not only in PNG, it also sends data in several other formats as well.
This is how you layer the data on your leaflet map:
1. Download and install GeoServer in your local machine or server. (Mine it’s http://localhost:9090/geoserver/)
2. Create a workspace for your work.
3. Then create a store for your data files.
4. Now you can create your map layers by selecting the data files in your store.
5. You can change the way data plotted on the map by changing it’s styles and link the style to the layer.
6. You can preview the layers by clicking on “Layer Preview” and selecting the format you want (Mine its PNG).
Tumblr media
7. Go to the javascript file where your code for leaflet map is kept and add a tile layer
var layer= L.tileLayer.wms("http://localhost:9090/geoserver/wms", {                                          layers: 'workspaceName:LayerName',    
                           format: 'image/png',   
                           transparent: true,   
                           version: “1.1.1”
}); 
8. Now you may see the data layer plotted on your leaflet map.
Tumblr media
0 notes
randomscameacross-blog · 10 years ago
Text
Generating Color Scheme
Say you want a new awesome color scheme for your new website. There are so many online services available to generate your pallet for free. From that I found http://coolors.co/ is very simple to use service which allows you to download your color pallet in pdf, sccs, png or svg formats.
Another color scheme generator I came across is CSS Drive Color Pallet Generator where I can upload an image with the color codes I want to identify and put it into a pallet. This is a really awesome tool when all we have is a screen shot of our favorite website design and no clue of the color codes.
Tumblr media
CSS drive color pallet generator
Have fun with generating new color schemes! Don’t forget to comment  about  your favorite color scheme generator.
0 notes