Skip to main content

Posts

No bluetooh headphone mic on Ubuntu 18.04

 Recently I purchased the  realme Buds Wireless in-Ear Bluetooth  headphone for my work from home setup, when I setup the headphone I found that Ubuntu is not able to detect the headphone mic, after installing APTX, ophone and doing numerous tweaks I;m not able to connect to mic. Then I came to know about its limitation of PulseAudio and there is new audio lib PipeWire which is better than PulseAudio. Follow below steps in order to get you mic back. sudo add-apt-repository ppa:pipewire-debian/pipewire-upstream sudo apt update sudo apt install pipewire gstreamer1.0-pipewire libspa-0.2-bluetooth sudo apt install pipewire-audio-client-libraries  sudo touch /etc/pipewire/media-session.d/with-pulseaudio sudo sed -i 's/.*bluez5.msbc-support.*/    bluez5.msbc-support = true/' /etc/pipewire/media-session.d/bluez-monitor.conf sudo sed -i 's/.*bluez5.sbc-xq-support.*/    bluez5.sbc-xq-support = true/' /etc/pipewire/media-session.d/bluez-monitor.conf systemc...

Login Loop in Ubuntu 18.04

If you are like me frustrated and pulling hairs for fixing login loop in Ubuntu GNOME DE, and you tried everything that's written their on internet like purging nvidia, removing .Xauthority file, chmod/chown /tmp folder and so on... then let me tell you my friends what really works for me :) First of all there is something kicking out us from spawning DE and in order to see that we must see the logs and understand if anything not happening right, for that just scroll the logs ctrl + alt + f1 $ journalctl -xe | less and here my friends after closer look I found that gnome-shell extension are messing up with my DE boot, and just simply removing extension dir, voila I can login 💃 $ rm -rf ~/.local/share/gnome-shell/extensions $ reboot I hope this solves your issue too..

Installing i3lock-color on Ubuntu

i3lock is fancy lock screen for Linux. There is i3lock dep available on Ubuntu but its not what I was looking for; I was more interested in i3lock-color . Lets see how we can install the same on ubuntu. PS: I'm using Ubuntu 16.04 Get source code for i3lock-color $ git clone https://github.com/PandorasFox/i3lock-color.git  $ cd i3lock-color Install required packages to build i3lock  $ apt install libev-dev $ apt install libxcb-composite0 libxcb-composite0-dev libxcb-xinerama0 libxcb-randr0  $ apt install libxcb-xinerama0-dev  $ apt install libxcb-xkb-dev  $ apt install libxcb-image0-dev  $ apt install libxcb-util-dev $ apt install libxkbcommon-x11-dev $ apt install libjpeg-turbo8-dev  $ apt install libpam0g-dev Build  $ autoreconf -i && ./configure && make Execute $ ./lock.sh Assign Shortcut In order to assign shortcut, install compizconfig $ sudo apt-get install compizconfig-settings-manager co...

Ubuntu 16.04: Office WiFI not connecting

I recently changed my office login password and after messing with my current wifi settings am not able to connect to wifi given credentials and all other expected settings are correct. This happens on Ubuntu 16.04 and found out that you need to manually enter settings into a disk file and make changes there.. Strangely, you wont find this settings in network manager UI, you have to manually enter this settings into file.. Open your wifi network file at below location and add/edit below properties. $ /etc/NetworkManager/system-connections/< > [802-1x] eap=peap; identity=< > phase2-auth=mschapv2 password-flags=0 password=< > system-ca-certs=false

Ubuntu Setup

I just moved to Ubuntu from Windows for numerous reasons and as I'm setting up my Ubuntu I have listed few points for future me. Here it goes.. Update Java Ubuntu 14.04 comes default with Java 7, I need Java 8 for new projects and Java 6 for some legacy projects. http://ubuntuhandbook.org/index.php/2014/09/install-oracle-java-ubuntu-1410/ https://ubuntuforums.org/showthread.php?t=2218888 Clean existing JDK sudo apt-get purge openjdk* sudo apt-get purge icedtea-* openjdk-* sudo dpkg --list | grep -i jdk java -version javac -version which javaws Update sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer java -version sudo apt-get install oracle-java6-installer java -version sudo apt-get install oracle-java8-set-default java -version Update GIT sudo add-apt-repository ppa:git-core/ppa sudo apt-get update sudo apt-get install git git --version Eclipse - Install Neon http://ubuntuhandbook.org/in...

Serlizing JSON polymorphically when type field is in parent JSON using Jackson

Today, I came across a json parsing situation where the sub-type field is outside the type json. Genrally we seen a situation like this @JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class") class Animal{} class Dog extends Animal{ } class Cat extends Animal{ } and it de-serialize to json like this: {      "@class" : "x.y.z.Cat", ... } In my project I need to parse json like this { "status": "OK", "messageName": "x.y.z.Success", "messagePayload": { "foo": "cd3a5697", "bar": 224 } } { "status": "ERROR", "messageName": "x.y.z.Error", "messagePayload": { "errorCode": "APPLICATION_ERROR", "errorInstanceId": "b292b864", "errorDetailedMessage": "Invalid UUID string (Length mismatch)" } } ...

My first C program: now and then

I was searching for some documents in gmail and found a mail that I sent to company X for their hiring process. It was a c program for searching word in file. I do not know how much time I have taken for it but it was basic search utility function. The point of this blog is not discuss that program but to discuss how time makes you better programmer. Here are the few things I would like to share myself - It takes some learning to write clean code.  Reed books like clean code. You need mentor to learn from his experience. Get a github account and see how experts are writing code. This is not the complete list, there are many things you will acquire over a period of time which make you better programmer. PS: If you are wondering how that program used to look like, then see this  repo.

Again writing fast & maintainable integration tests using in-memory db, liquibase, gradle and spring mvc test

This blog is improvisation to previously blogged testing effectively with database blog . In this blog we will remove the jetty setup and instead use Spring MVC Test framework which kind of simulate the request/response for your controllers via Spring Web Application context (no deployment, to http client tests) Here, we will write Spring MVC tests and - Create the HSQLDB in-memory instance (instantiating datasource instance) and run Liquibase scripts against them. (using Spring Lqiuibase bean) 1. Setup your web-service. Write usual Controller->Service->Repository layer. @Controller @RequestMapping("/reports") public class MapAnomalyReportEndpoint { @Autowired private MapAnomalyReportService reportService; @ResponseBody @RequestMapping(method = RequestMethod.GET) public Collection getReports() { return reportService.getReports(); } } 2. Create Spring Java Config (No XML) Configure the controllers. @Configuration @Enabl...

Writing fast & maintainable integration tests using test double, in-memory db, jetty, maven and spring

Writing an integration test which test end to end flow of your application can become cumbersome activity if you really hitting real db and services. The best way to mock, test double your external dependencies and thus speed up your test execution. I created a dummy map-service project which demonstrate about writing maintainable and speedy integration tests using mocking, test double pattern, spring and automating them using maven and jetty. You can find the project at my github location: https://github.com/sagarr/maps-service Here are some code snippets explaining the important steps in configuring your project. POM - Configure jetty for deploying your app and running tests against it. . org.mortbay.jetty jetty-maven-plugin ${jettyVersion} /${project.artifactId} 8005 STOP 5 true 8080 60000 start-jetty pre-integration-test run 0 true stop-jetty post-integration...

Code Kata - good way to learn new language

Recently, I started exploring and learning Scala and functional programming. So far, it is a good experience and as a programmer gives you new "functional" thought process about problem. The best way to learn Scala or any language for that matter is to start writing Katas in that language. Coding Kata, if you're not familiar with it then must visit codingdojo.org . In short, coding kata is programming practice mostly done in TDD way, which makes you better programmer. BTW, If you're wondering where are my katas in Scala, you can find them here: https://github.com/sagarr/scala-dojo

A Day of Innovation: TomTom Pune DevDay 2013

Friday (6 April 2013) was a day of innovation and engineering, fun and quiz, it was a first TomTom Pune Engineering DevDay. Key Highlights of the day: Kick started with U2 public concert video, a good way to wakeup people. Many speaker talked about how we can extend and experiment with our new generation map editing tool Cartopia I talked about function programming and how we can achieve it using Scala. There were coffee breaks with testers which showcase some really cool technologies like puppet, test automation using FlexPilot and risk based testing's. Day end with exciting quiz, prize distribution and beer :) If you want to be a part of next TomTom devday, join us http://www.tomtom.jobs

Adjustable flex datagrid row height for multi-level tree component

Note: This blog is extension to the post blogged here , the OP has used one level tree to display in grid, whereas I used multilevel tree. From last 2-3 months I'm working on Flex, developing our in-house map editor. We've a requirement to show a grid with some column containing multilevel tree data, I googled it and found the above link which was matching to our requirement but got one problem, it didn't work correctly for multilevel tree. The problem is - It failed to adjust height when you expand inner child element. The whole tree get collapsed when you collapse the inner element. To provide a solution to above problems, you have to - Keep a flag which tells if root is closing or not, if root is closing keep the original height. For all other child expansion, count the children from existing "open items" and adjust height accordingly. The below code explains it all.

Tests your logs using logback

You want to test what your application logging and you don't know how to do that in simplest manner, well we've logback to rescue. (If your using slf4j but with other than logback as a implementation, then you have to add logback as a test dependency with logback.xml in src/test/resources) One (not exactly) caveat is that, for testing logs using logback we need to use Mockito for creating mock Appnder and asserting for the exact log string in argument. Here is the actual code- 1. Create a base test class for log testing. public abstract class BaseLoggerTest { final Appender mockAppender = mock(Appender.class); @Before public void setup() { when(mockAppender.getName()).thenReturn("MOCK"); (ch.qos.logback.classic.Logger)LoggerFactory .getLogger(ACCESS_LOGGER_NAME)) .addAppender(mockAppender); } protected void verifyLog(final String expectedLog, final Level level) { verify(mockAppender, atLeastOnce()) ...

Good Vs Better Programmer

We always have some good programmers around us who are capable of doing work at hand, but to success in long term we need better programmers. Here are some traits I found important to become better programmer. Good programmer start coding right away after picking up the task, better programmer first do some little design upfront (may be draw some UML, flowcharts etc), write the simplest readable tests first and then write minimum production code which makes that test pass. Good programmer stick to the tool, framework, workflow he/she knows best, better programmer keep the affinity towards any technology aside and evaluate and use the best possible tool, framework available.  Good programmer focuses on working code, better programmer too focused on working code but also gives the utmost importance to code readability, flexibility and other design principles . Good programmer ever read technology books when he/she was in college, better programmer subscribed to feeds, question...

How to test objects equality if they don't implement Object#equals()

Problem: There are cases when you want to test whether two objects are equal, mean did they contain same state or not ? This occurs mostly when you're trying to test JAXB generated beans or any VO/DTO which doesn’t' implement Object#equals() method or/and whose source code you can't modify . Solution: I knew there is a class (Commons lib's EqualsBuilder class) available which "reflectively" creates the equals method for you taking care all the rules for writing good equals method. But that class doesn’t have a method to test whether two object are equal or not. At back of my mind, I know Mockito library internally uses the same commons class to solve my problem. I quickly scan the mockito jar and found this class. Here is the code snippet for the same (please note, you have to add mockito jar on classpath for this) import org.mockito.internal.matchers.apachecommons.ReflectionEquals; . . . public <T> void assertObjectEquals(final T expected, final T...

PIT Tests, a Mutation Testing

While wondering over internet, I just come across the "mutation testing" and here I blog about it. The blog largely said about one such framework " PIT tests ". When we say my code coverage is 80%, that only mean, in simple term, your unit tests cover 80% of your code base. Do they really tell you what your tests are really testing? - No. To answer this, there is a thing that called as "mutation testing". The framework I am talking about is PIT tests; they said it’s like automation tests for your tests. Cool! How does it work? Well in plain simple language, it mutate (modify the byte code at runtime) some logical part, decision taking part of your code and then run tests against such modified code, if your test fail (called as mutation killed), your test is OK, if its passed (called mutation survived), beware, there might be some bug hidden there. So, more the mutation killed more good your tests are. Example: The simplest example might be, if ( ...

Not 10, but 6 things about jMeter

I list down some "good to know" things about jMeter. Hope it helps you while considering the jMeter scripts design, development and execution.   Its open source Java tool for functional and load testing. Can be "extended" to create new sampler, controller etc. Module Controller - If your scripts are going heavy and you found many copy-paste steps; in that case just create a module of those steps. Module is like a function in programming. Include controller - Some modules are global and can be used in many scripts, in that case just include that JMX into your main JMX, like you include JSP tag. Parameterized Controller - Third party controller which enable us to pass various runtime parameters to sample. Usually sits on top of module controller. http://code.google.com/p/jmeter-plugins/ jMeter scripts can be executed from ANT, it help in automating the daily execution of scripts. (Can be triggered from nightly build process from your CI server): http://www.pr...

VM arguments in spring context

In case you trying to access the VM arguments in spring application context, then just add the below bean definition in context file: <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="ignoreUnresolvablePlaceholders" value="true"></property> </bean> And access the VM args as ${vm_property}, e.g if you passed the –Dfoo=bar, which can be access as, <bean class="com.company.test.MyClazz"> <property name="myProperty" value="${foo}"></property> </bean>

Quick Fix: Selenium + FireFox 4

Being a firefox fan, I just updated my current FF (3.6.x) to FF 4, everything goes well and I could see much improved FF both performance and UI wise, but I couldn't use selenium IDE with it (Yes, some time I do UI testing), so after some googling found 2 solutions: Solution #1: If you already have the selenium installed but its disabled because it's not supported by FF 4 yet, the fix (hack) is explained here (See Mark Collin reply) Solution #2: If you don't have selenium IDE installed, then simply download the latest supported but not yet released selenium IDE installer from here and install it just by dragging or opening it to FF window.

What I've learned from TDD

TDD, I'm practicing development using unit test from 1 year now and frankly speaking I'm loving it. I listed some points/notes/importance I learned from TDD. You might like to add some points or want to correct me, so please comment. Here the list goes: Caught 80% of bugs at first place before your code goes to production. Explore and forces to think the development and design in proper Object Oriented way, means less class dependencies, loose coupling's, SRP etc. You can fearlessly do refactoring and enhance the quality of existing code if you have enough unit test code surrounding. If you have been reported any bug/issue in production code, write the unit test that produce that bug and fail(red), then fix the code(refactor) and ultimately make the unit test to success( green). Gives idea about the usage of API you're developing. I know this are not the only points which make TDD incredibly great practice, but I'll update this blog for some more points as...