Posts

Calculate Swatch Internet Time Codes

PHP 12 bytes: <?php echo date('B'); ?> 48 bytes: <?php echo sprintf("%03d",((time()+3600)%86400)/86.4|0); ?> C,  56 bytes main(){printf("%03d",(int)((time(0)+3600)%86400/86.4));} Explanation: %03d  - tells printf to zero-pad up to 3 digits. time(NULL)+3600  - gets amount of seconds (UTC) elapsed since epoch and adds an hour to it (UTC+1). %86400  - divides epoch by the amount of seconds in a 24hr day and gets the remainder (representing seconds elapsed, so far, "today"). /86.4  - divide remaining seconds by 86.4 to get the ".beat" count since midnight (UTC+1). Compile (MSVC): C:> cl swatch.c Compile (GCC): $ gcc swatch.c Java 143 bytes import  java.time. * ; interface A  {   static void main(String[] a) {     System.out.format("%03.0f" ,  LocalTime.now(ZoneId.of("UT+1")).toSecondOfDay() / 86.4);    } } Javascript d=new Date();t=;console.log(Math.floor((360*d.getHours()+60*d.

Linux Clear Cache

#!/bin/bash #clean page cache #sync #echo 1 >/proc/sys/vm/drop_caches #clean dentries and inodes #sync #echo 2 >/proc/sys/vm/drop_caches #clean page cache and dentries inodes, but it is not recommended in production instead use "echo 1" #sync #echo 3 >/proc/sys/vm/drop_caches ################## # begin refresh script ################## sync if [ $(dpkg-query -W -f='${Status}' polipo 2>/dev/null | grep -c "ok installed") -eq 0 ]; then apt-get install polipo -y fi polipo -x echo 3 >/proc/sys/vm/drop_caches swapoff -a && swapon -a printf '\n%s\n\n' 'Ram-cache and Swap Cleared' /opt/lampp/xampp restart free -h this script used for better performance your vps (LINUX). fix apache slow response fix xampp web server slow fix overload ram vps fix mysqld overheat fix java machine overheat ram

Android Studio Fix Issues

Image
Unsupported Modules Detected in Android Studio File -> Invalidate Caches / Restart. Close the project and Android Studio. Remove the .idea directory and all .iml files. Reopen Android Studio and import your project. If it doesn't help could you please try to reproduce this issue on the empty project and let me know about results.

PHP array magic trick and manipulations

manipulating multidimensional array using array_map /** * Ilterate multidimensional array simplicity * @desc modify and manipulate or populate multidimensional array with simple tricks * @param array $arr * @param function $callback * @return Array **/ function Map($arr, $callback) { if (!is_callable($callback)) { throw new Exception("Callback must be function", 1); } return array_map(function ($key, $val) use ($callback) { return call_user_func($callback, $key, $val); }, array_keys($arr), $arr); }

VSCode

Install jQuery Auto Complete and Hinting on VSCode - Required  npm - Syntax Terminal npm i -- save @types / jquery

Project lists for beginner

Movies App (Flutter Project)

Android Studio Set Weight Layout Programatically

Image
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, //OR WRAP_CONTENT -> layout_width LayoutParams.MATCH_PARENT, //OR WRAP_CONTENT -> layout_height 1.0f // layout_weight 1 ); YOUR_VIEW.setLayoutParams(param);