Development of Crunchbang has now stopped. There are a few community spin-offs available, Bunsen Labs and Crunchbang++. I’m now using a netinst version of Debian at home with the i3 window manager, and Bunsen Labs on my office laptop. Both are working well. I’m still using the same set of software for my work, in addition to a few more, so this post is still valid.
I’ve been using Linux at home and work for over 5 months now. I’m using a Debian based distribution called Crunchbang. Over these past few months I’ve developed/programmed using multiple technologies and have gathered a collection of tools, that I use on a daily basis.
I’ve been working with PHP and jQuery AJAX quite a bit lately. Along with sending form data to PHP page through AJAX, I’ve written restful web services in PHP that receive data in JSON format.
In general when you are sending data through jQuery AJAX to PHP, you don’t have to specify a contentType. Depending on your type ‘GET’ or ‘POST’, PHP will nicely wrap your content into either the $_POST or $_GET global arrays. When you don’t specify a contentType the default contentType is taken as application/x-www-form-urlencoded; charset=UTF-8’.
Following is the request headers from an AJAX call without contentType specified,
Obviously, PHP has no issues parsing content of type – application/x-www-form-urlencoded; charset=UTF-8. As soon as it sees that contentType, it checks the action and packs the data nicely into either $_GET or $_POST.
Let’s now talk about JSON data. In general, restful web services accept data of type JSON. When sending data via JSON the contentType for jQuery AJAX is application/json; charset=UTF-8
When PHP receives this data and looks at the content type, it’s not quite sure how to process it, so it leaves it alone. In this case the action – ‘POST’ or ‘GET’ doesn’t matter. You’ll notice that $_POST or $_GET both, are empty arrays. Now, it’s up to you to read this data and parse it.
The code above, reads the data from PHP’s input stream. Since we have passed a JSON string, we decode it, which converts it to a PHP array and stores it in $app_json. If the data you send is not in a correct JSON format, $app_json will have false.
When we echo our response, we get the following on the client side,
There are instances where the PHP function – get_results will not work on CentOS (this maybe the case with other Linux based operating systems as well). I faced this issue while deploying a project on CentOS which was originally developed on Windows. All my INSERT, UPDATE and DELETE database statements were working properly, but bulk SELECTstatements had issues. Closer inspection narrowed down the problem to the get_results function.
This post assumes that the reader has a basic understanding of PHP, jQuery and jQuery $.post
Recently I had to implement a windows-esque tree view based file explorer for one of my projects at work. I ended up using this wonderful jQuery plugin to help me. In this blog I’ll be going through some basic code to get it working using PHP on the server side.
To whet your appetite, here’s what we’ll be achieving in this blog post – A complete tree view based file explorer that feeds from a folder on the server’s file system.
So let’s get started!
To be able to render a proper tree using the aciTree plugin, we’ll need to send JSON from server in the following format –
Here’s the list of things that we’ll be doing –
Server Side Code
Basic event handling for the aciTree plugin.
1. Server side code
Let’s move onto the PHP code. Our job is to read the files from the specified folder and return a JSON structure that resembles what’s shown above. If you look closely you’ll observe that the JSON above is basically an array of objects of with properties as – id, label, inode, icon, open
The following class is exactly similar to that of the class received via JSON. We’ll be returning an array of NodeList objects from the server.
* Represents each node in the aci tree jquery plugin
Development of Crunchbang has now stopped. There are a few community spin-offs available, Bunsen Labs and Crunchbang++. Although most of what’s been written here should be applicable to these distributions, it hasn’t been tested. I’m now using a netinst version of Debian at home with the i3 window manager, and Bunsen Labs on my office laptop. Both are working well.
Last Friday, I installed Crunchbang. It is a Linux distribution derived from Debian. The purpose of this post is to outline the various steps I followed to get Crunchbang ready for use. I can then refer to this post whenever I’m setting up my system again, or helping someone else set up theirs.
I’ll start of with my computer specifications first. This might help people with similar hardware configuration to find a solution to their problems.
Intel i5-4570 CPU @ 3.20GHz
6.00 GB RAM
MSI HD 7850 Hawk
Philips 190VW (1440 X 900) Dell S2240L (1920 x 1080)
Once Crunchbang is installed and you boot up for the first time a handy script starts up that allows you to update your system and installed software. This script can be invoked later on as well by running cb-welcome command on the terminal.
Installing LAMP and Java
Follow the script and install Java and the LAMP stack. It is also possible to install – Git, SVN and drivers for printer.
Installing AMD Proprietary Driver
After the script has finished, it’s time to install the graphics driver.
Okay, so driver installation is over. It’s time to set up dual monitors. By default, after you’ve installed Crunchbang on a system that has dual monitors and an AMD graphics card, the monitors will duplicate each other. Once you’ve installed the driver you can change that setting. Fire up the AMD Catalyst Control Center by running amdcccle command on the terminal.
Change the mode to extend the display to two monitors rather than duplicate the display –
Placing monitors in the correct order (left or right of each other) is as simple as dragging them into place. You can also change the resolution from this screen.
Another problem that people with DELL S2240L and AMD cards will have that the display on the monitor won’t re-size to fit the entire screen. The fix for that is available through CCC –
Note that the CCC makes changes to the xorg.conf file in /etc/X11. If you don’t want to make these changes everytime you reinstall Crunchbang, just backup that file.
Installing Logitech Wireless Driver
I have a wireless Logitech keyboard. With the new motherboard the keyboard is not auto detected by Crunchbang. Installing the driver found here and then restarting resolves the issue.
Conky is basically a system monitor software for the X Window System. It can be extend via plugins and can be customized to show things such as weather.
Tint2 is a task-bar designed to be simple and lightweight. Here’s my tint2 config file.
My Conky configuration can be found here. The result –
That’s it. That’s all I do once Crunchbang has been installed. It took me about four hours hours, but with this post as a reference, next time I should be able to reduce that time to about an hour.
Crunchbang is wonderful distribution that is minimalist, fast, stable and extremely customizable. It runs very well on old and new hardware. They have a helpful and friendly community. So, if you are looking for a new Linux distribution to try out, do give Crunchbang a test drive.
My current assignment at work has me working through a lot of old code. Code that now needs to be modified to implement new features and remove bugs. While updating or modifying existing code it is very important to insert comments stating why the modifications were carried out and the date on which they were carried out. Eventually when other developers work on the same piece of software and compare revisions, they shouldn’t be left wondering why a certain modification was made.
Unfortunately, Visual Studio lacks insert date time at current position functionality. But what it does support are Macros, and using those, it’s quite easy to implement that feature ourselves.
Macros are written in VB.NET. The following VB.NET code can be used to insert the date time at the current caret position –
Dim selection AsTextSelection=DTE.ActiveDocument.Selection
The code above creates a module called PrintDateTime.
It then inserts current date time at the currently selected caret location.
Next step is to place this code in the correct place.
Open up the Macro explorer by pressing ALT + F8.
In the Macro explorer right click on Macros, and click on ‘New Macro Project’.
Give it a name, and once it’s created, it should be visible in the Macro explorer.
Create a new Module under the project and give it a name that relates to what you are doing
Double click on the new Module to open a Macro editor.
Paste the code above in that editor and save the file.
Now that that is done, your Module should be visible under your project. The next thing we have to do is to assign our newly created Macro to a shortcut key, so that we can easily run it whenever we want.
On the file menu, click on Tools > Options
On the window that opens up, in the tree view, go to Environment > Keyboard
In the Show commands containing textbox, type the name of the Module you created earlier and it should show up in the list below the textbox. Select it.
In the Press shortcut keys textbox, press the combination of keys that you want to use whenever you wish to run your Macro.
Make sure Global is selected under Use new shortcut in: and then press the Assign button, followed by OK.
It’s time to see if what we did works! Open up a document and press the same combination of keys that you used to create the shortcut. Once you do, the date time should be inserted at your current caret position and this should work for any document that you create inside Visual Studio 2010.