Monday, August 28, 2023

Grails / GORM apply criteria query with hasmany String for filter

I have a domain object (User) like this:
class User {
   String name

   static hasMany = [
      permissions: String
   ]
}
And I am trying to query all the User with certain permissions. So I have to join and check permissions property. Here how we can do this -
User.withCriteria {
    createAlias('permissions', 'n') 
    ilike 'n.elements', '%permission_1%'
}
The trick is to use 'n.elements'

Friday, July 28, 2023

Bootstrap 5 Multiple Modal Overlay | How to use multiple modal in bootstrap?

Let me explain my problem, I am using bootstrap modal for my project. That is fine but I get stucked when another modal open over first modal. To solve this problem I added below javascript code to my project and it get solved.
$(document).on('show.bs.modal', '.modal', function() {
    const zIndex = 1040 + 10 * $('.modal:visible').length;
    $(this).css('z-index', zIndex);
    setTimeout(() => $('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack'));
});
Now my modals are looking like below:

Friday, March 24, 2023

Foods That Will Not Affet Diabetics

Diabetics should avoid fruits with a high GI or eat them in moderation so that their blood sugar levels do not spike abruptly. Pineapple, watermelon, mango, lychee, and banana have a high GI, so these are the worst fruits if you are diabetic.

Below foods are good to continue even you have diabetic

1. Oranges
2. Chickpeas (Garbanzo Beans + Chola Chana) or Chickpea flour as well
3. Green Vegetables
4. Nuts and Peanut Butter
5. Probiotics
6. Cinnamon
7. It is normally recommended to consume 6-8 ALMONDS a day but for a diabetic patient, the quantity should be more
8. Cashew nuts (Kaju Badam) contain high levels of beneficial fats, the consumption of which can raise the good cholesterol and reduce the bad cholesterol levels, and thereby reduce the risk of heart disease. Undoubtedly, they are one of the best nuts for diabetes.
9. Green Apples, Grapes are not alarming to diabetics.
10. Custard apple (Sitaphal or Sharifa) has a low glycemic index of 54 that makes it a good choice for diabetes. Custard apple is good for digestion and boosts immunity for a diabetic. It aids in better vision and prevents high blood pressure or hypertension. It is recommended that a diabetic consumes 1 full custard apple every alternate day. read more here

Some additions:

Ginger is incredibly versatile and a staple in alternative medicine. People have used it for centuries to improve many aspects of heart health, including circulation, cholesterol levels, and blood pressure. Both human and animal studies have shown that taking ginger reduces blood pressure in several ways.
Coconut is excellent for diabetics as it helps regulate blood sugar levels as it has a lot of fiber. It has a low carbohydrate content but a high fiber and fat content instead.

Thursday, March 16, 2023

How to Disable the Built-In Laptop Keyboard in Windows

Disable your Windows laptop's keyboard and migrate to a bigger one with these tips.
Sometimes you don't want your laptop's keyboard to take inputs. This is usually because you're plugging in an external keyboard, either because the built-in one is broken or you just want a larger typing space with a full-sized keyboard.
However, the keyboard being an integral part of your portable computer, disabling its primary input method is a little tricky. Here, we show you how to permanently disable the laptop keyboard in Windows.
For this, you’ll need to identify the integrated keyboard in Device Manager. Since Device Manager will list all the recognized keyboards, including external keyboards, here’s how you can identify your laptop keyboard from the list.
1. Press Win + R to open Run.

2. Type devmgmt.msc and click OK to open Device Manager.

3. In Device Manager, expand the Keyboards section.

4. From this step you will get the keyboard driver id as red marked in picture.

5. Now Press the Win key and type cmd in the Windows search bar.

6. Right-click on Command Prompt and select Run as Administrator. Click Yes when the UAC prompt appears.

7. In the Command Prompt window, type the following command and press Enter:

sc config i8042prt start= disabled

8. When the success message appears, close the Command Prompt, and restart your PC. After the restart, your laptop keyboard will stop registering any inputs.

9. If you change your mind and want to re-enable the keyboard, you can use the following command

sc config i8042prt start= auto

Saturday, February 11, 2023

Clear Git Bash History | HowTo: Clear BASH History | How to clear bash shell history command

Sometimes you don’t want to leave Bash history, because it may contain some sensitive data (e.g. passwords, tokens, etc.).
To completely erase the Git Bash history you need to locate and delete the .bash_history file and then run the history -c command.
Run these commands in the Git Bash to locate and delete the .bash_history file:
User@Computer MINGW64 ~
$ echo $HISTFILE
- sample output -
/c/Users/<username>/.bash_history

User@Computer MINGW64 ~
$ rm /c/Users/<username>/.bash_history

User@Computer MINGW64 ~
$ history -c

How do I disable my HP laptop keyboard and use an external keyboard | How to turn off a laptop keyboard | Permanently disable laptop keyboard

Understandably, Microsoft makes it a bit more difficult to permanently disable the keyboard. To do so, you’ll have to turn off Windows’ ability to automatically install the driver again. Without doing this, the keyboard will be back up and running every time you reboot your device.
  • Open the Start menu and type group policy into the search bar
  • Click the result named Edit group policy and the Local Group Policy Editor window should open
  • Now expand Computer Configuration then Administrative Templates then System followed by Device Installation then Device Installation Restrictions
  • Right-click the option marked Prevent installation of devices not described by other policy settings and choose Edit
  • From the window that appears, click the circle next to Enabled to select it and click OK to confirm
  • Now Open the Start menu and type device manager into the search bar or press Window + X button at the same time
  • Open the Device Manager, then find the Keyboards heading and double-click it
  • You should see two or three drivers listed here. Right-click on the keyboard you want to unstall and select action Uninstall or Uninstall device
  • For my case it's the keyboard named Standard PS/2 keyboard
  • It will require restart sometimes, and task completed

Thursday, February 9, 2023

How do I Refresh on page Focus - Web Development | How to refresh page after focus on browser tab

I would like to refresh a page after it got back into the focus
The tricky part is how do I determine when to refresh? Because ta may get focused many times in it's lifecycle.

First the window has to loose the focus (which could be determined through .blur() I assume and hope will work this way).

Only after the window which lost focus gets back into focus should trigger the refresh of itself and thats it.
In my development environment I added below snippet of JavaScript to the expected page - whenever the page becomes active after becoming inactive it reloads automatically, so for example if you type in your text editor then click back onto your browser the page will reload once without an infinite loop. It also works when chaining active tab or active window within the same browser session will occur.
var blurred = false;
window.onblur = function() { blurred = true; };
window.onfocus = function() { blurred && (location.reload()); };