Skip to main content

Posts

Showing posts from February, 2022

Debounce and throttle script

  function debounce (fn, delay) { var timer = null ; return function () { var context = this , args = arguments ; clearTimeout(timer); timer = setTimeout( function () { fn.apply(context, args); }, delay); }; }   $( 'input.username' ).keypress( debounce ( function (event) { // do the Ajax request }, 250 )); function throttle (fn, threshhold, scope) { threshhold || (threshhold = 250 ); var last, deferTimer; return function () { var context = scope || this ; var now = + new Date , args = arguments ; if (last && now < last + threshhold) { // hold on to it clearTimeout(deferTimer); deferTimer = setTimeout( function () { last = now; fn.apply(context, args); }, threshhold); } else { last = now; fn.apply(context, args); } }; }     $( 'body' ).on( 'mousemove' , throttle ( function (event) { c...

React Hot Reload Issue in Ubuntu.

  React Hot Reload Issue in Ubuntu. Added this to store.js file if (module.hot) { // Enable Webpack hot module replacement for reducers module.hot.accept('../reducers', () => { const nextRootReducer = require('../reducers/index'); store.replaceReducer(nextRootReducer); }); } Commands > sysctl -a | grep inotify ( Output might be ----> user.max_inotify_watches = 524288 ) > sudo gedit /etc/sysctl.conf (append " fs.inotify.max_user_watches=524288 ") > sudo sysctl -p /etc/sysctl.conf (to apply changes)

Run zenity or any other GUI based program through cron.

 a shell script file like and following code and then add shell script in cron. Cron Entry * * * * * /var/www/html/runcron.sh Shell Script #!/bin/bash touch /var/www/html/tfile dbus_session_file=/home/suntec/.dbus/session-bus/$(cat /var/lib/dbus/machine-id)-0 if [ -e "$dbus_session_file" ]; then   . "$dbus_session_file"   export DBUS_SESSION_BUS_ADDRESS DBUS_SESSION_BUS_PID   dbus-send … fi zenity --error --text='Fill Time sheet' --display=:0.0