Skip to main content

Posts

Java 8 JMX Default Metrics

This is more of a note. Here you can find default types and attributes for JMX on top of Java 8. Code: I will clean and explain it later :( private static void WriteAttributes(final MBeanServer mBeanServer, final ObjectName http) throws InstanceNotFoundException, IntrospectionException, ReflectionException { MBeanInfo info = mBeanServer.getMBeanInfo(http); MBeanAttributeInfo[] attrInfo = info.getAttributes(); System.out.println("Attributes for object: " + http +":\n"); for (MBeanAttributeInfo attr : attrInfo) { System.out.println(" " + attr.getName() + "\n"); } } Attributes for object: java.lang:type=MemoryPool,name=Metaspace:   Name   Type   Valid   Usage   PeakUsage   MemoryManagerNames   UsageThreshold   UsageThresholdExceeded   UsageThresholdCount   UsageThresholdSupported   CollectionUsageThreshold   CollectionUsageThresholdExce
Recent posts

How to set JAVA_HOME environment variable on Mac

Note : This tip is for Mac OSX 10.5 or later Apple recommends to set the $JAVA_HOME variable to /usr/libexec/java_home , just export $JAVA_HOME in file ~/. bash_profile You might not have .bash_profile present on your system already. No worries we will create/update the profile in next step. Open Terminal: $ vi ~/.bash_profile Initially the vi editor will not be in edit mode, press 'i'. Update file by exporting variable: export JAVA_HOME=$(/usr/libexec/java_home) to the file (in the vi editor which we opened using the previous command) Saving and Closing the .bash_profile file opened inside vim editor: Press escape (while still inside the vi editor) type ":wq!" or press "Shift + zz" to save and exit the file.

Laravel XAMPP MySQL artisan migrate install error mysql.sock

In my previous post I wrote about setting up Laravel 4 on Mac with XAMPP . When I tried to use migrations (using artisan) I faced some issue. I will also post about Laravel migrations soon.    php artisan migrate:install Error :                                                     [PDOException]                                       SQLSTATE[HY000] [2002] No such file or directory                                              Solution : We need to tell artisan which mysql we want it to use. For this to work we need to porivde it with mysql.sock which we want it to use. So change your database settings like this: 'mysql' => array( 'driver'    => 'mysql', 'host'      => 'localhost',     'unix_socket' => '/Applications/xampp/xamppfiles/var/mysql/mysql.sock', 'database'  => 'wedding', 'username'  => 'root', 'password'  => '', '

Working with MySQL on MAC. GUI Client, Web Based and Terminal

MySQL is most popular open source relational database. I have been using it myself for my PHP, Python and Ruby projects. Obviously, we need some client(s) to access MySQL database. In this post I am going to list down few clients.  Environment: I am using XAMPP on Mac. You can install MySQL separately if you want to. 1. Desktop GUI client Use SequelPro it is a nice tool and free.  Set it up and you are ready to go. 2. PHPMyAdmin phpMyAdmin is a free software tool written in  PHP , intended to handle the administration of  MySQL  over the Web. It gets setup with XAMPP.  3. Terminal Open up terminal and execute following commands -  Go to the directory with mysql binaries cd /Applications/XAMPP/xamppfiles/bin; Access mysql command line tool using ./mysql --user=root --password=

Setting Up Laravel 4.x on Mac OSX 10.8+ with XAMPP installed

I am new to PHP and have coded earlier with CodeIgniter. It is really easy to get started with CodeIgniter as it is light but powerful and has less features. As CodeIgniter is slowly phasing out I thought of moving to Laravel. Yes, it is powerful and AWESOME!!!  Lets get down to business.  1. Install composer I was doing it for the first time and faced issues: Some settings on your machine make Composer unable to work properly. Make sure that you fix the issues listed below and run this script again: The detect_unicode setting must be disabled. Add the following to the end of your `php.ini`: detect_unicode = Off A php.ini file does not exist. You will have to create one. I was clueless at this moment and started to search. After some search I found an article which tells about setting up AMP (Apache, My SQL and PHP) environment . While going through it I realized that I have Apache already installed on my system (I am new to Mac too). I followed the steps to configure i

Create custom UITextFields and UITextViews with underline

Download In a recent iOS project I needed to create custom UITextView and UITextField. The look and feel had to be same as the Notes app, i.e. the text view and text field both should have horizontal lines as are present in a note. How to create a custom UIView To create a custom UIView we need to inherit from UIView class. We then need to override drawRect method. Override only if you need to change the way view is drawn as this is a performance intensive operation. Custom UITextField In order to create custom UITextField I inherited my class from UITextField. I need to draw a bottom border for this I need override drawRect method. //Get the current drawing context CGContextRef context = UIGraphicsGetCurrentContext(); //Set the line color and width CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor); CGContextSetLineWidth(context, 0.5f); //Start a new Path CGContextBeginPath(context); // offset lines up - we are a

UITableView basic tutorial

In this tutorial we will create a table view with some dummy data, we will use disclosure indicator, change background color of cell, handle user selection, change separator color etc. There many tutorials which provides in depth information on UITableViews thus I will not touched that and instead targeted the practical How Tos. Create a new single view project and add a UITableView to the initial view controller which has been added to the storyboard automatically. In order to use UITableView in your viewcontroller you need to adapt to UITableViewDataSource and UITableViewDelegate.  UITableViewDelegate provides us with methods which let us handle user selection events, define row height, modifying view and much more. UITableViewDataSource provides data to UITableView to construct the view (to render content). Create table view cells, define the number of sections, number of rows in sections and much more. Adapt to required protocols @interface AYVie