Skip to main content


Showing posts from December, 2017

Playing around with IIFEs (Iffys)

So heres my take on the IIFE . We will first begin with understanding what really is IIFE, some simple examples of IIFE and what are the benefits it provides to a Javascript developer (Us!!!). Then we will look into some more advanced topics related to IIFE. What is IIFE? IIFE is Immediately Invoked Function Expression. In simple words these are the functions which are called immediately once they have declared. Commonly they are written like this: 1: (function () { // open IIFE 2: console.log("inside IIFE") 3: }()); // close IIFE This code, when executed will print "inside IIFE". Kindly note the syntax. The trailing parenthesis are the ones which do the magic of invoking this function immediately. If we remove the trailing parenthesis, then this code becomes just a normal function definition and nothing else. Also, dont miss the trailing semicolon, its required. Missing the trailing semicolon could cause some serious problems. For e.g. consi

Criteria query for a many to one relationship with join fetch

CriteriaBuilder cb = _entityManager .getCriteriaBuilder(); CriteriaQuery<Message> criteriaQuery = cb.createQuery(Message. class ); Root<Message> messageRoot = criteriaQuery.from(Message. class ); Root<Device> deviceRoot = criteriaQuery.from(Device. class ); Fetch<Message, Device> recipientDeviceFetch = messageRoot.fetch( "recipientDevice" , JoinType. LEFT ); Join<Message, Device> messageRecipientDeviceJoin = (Join<Message, Device>) recipientDeviceFetch; criteriaQuery.where(cb.and(messageRoot.get(Message. COLUMN_ID ).in(messageIdsToDelete), cb.equal(deviceRoot.get(Device. COLUMN_PRIMARY_KEY ), devicePrimaryKey))); class , messageRoot.get( "recipientDevice" ), messageRoot.get(Message. COLUMN_CLIENT_MESSAGE_ID ))); List<Message> messages = _entityManager .createQuery(criteriaQuery).getResultList(); return messages;

Deleting all the mysql databases from command line

Use this command: mysql -uroot -p<password> -e "show databases" | grep -vw Database | grep -v mysql| grep -v information_schema|  grep -v sys | gawk '{print " drop database "$1";select sleep(0.1); "}'| mysql -uroot -p<password> What it does is mysql -uroot -p<password> -e "show databases" -- This will return the list of dbs. In my case its result is: +--------------------------------------------------+ | Database                                         | +--------------------------------------------------+ | information_schema                               | | DarkConfigDatabase                               | | DarkMailDatabase                                 | | DarkServerActiveDatabaseMarkerDatabase           | | DarkServerAuditingDatabase                       | | DarkServerCardManagerDatabase                     | | DarkServerCertificateAuthorityDatabase           | | DarkServerC