Posts

Showing posts with the label Script

Full page blogger css

Image
How to show only content on blogger page <style> @media only screen and (min-width: 1025px) { #sidebar-wrapper, #midsidebar-wrapper, .gapad2, .blog-pager, .post-header-line-1, .post-footer { display: none !important; } #main-wrapper { width: 150% !important; /*98% default*/ } .post { width: 150% !important; /*98% default*/ } #comments { width: 150% !important; /*98% default*/ } .post-title, .post-labels, post-icons, post-author { display: none !important; } } </style> OR <style scoped="" type="text/css"> #outer-wrapper { margin: 0 auto; text-align: left; float: none; background-position: center !important; } #post-wrapper { width: 100%; max-width: 100%; margin: 0 auto; text-align: left; float: none; background-position: center !important; } .post-body, .post { background-position: cente

Fix Uncaught Error Call to undefined function str_starts_with()

Image
Uncaught Error: Call to undefined function str_starts_with() Fix Solutions if (!function_exists('str_starts_with')) { function str_starts_with($haystack, $needle, $case = true) { if ($case) { return strpos($haystack, $needle, 0) === 0; } return stripos($haystack, $needle, 0) === 0; } } if (!function_exists('str_ends_with')) { function str_ends_with($haystack, $needle, $case = true) { $expectedPosition = strlen($haystack) - strlen($needle); if ($case) { return strrpos($haystack, $needle, 0) === $expectedPosition; } return strripos($haystack, $needle, 0) === $expectedPosition; } }

Import composite build plugin as subtitue module dependency [Gradle]

Image
// change folder path inside bracket includeBuild("plugin") { dependencySubstitution { // change your artifact group and id // iam using https://github.com/dimaslanjaka/gradle-plugin/ for example substitute(module("com.dimaslanjaka:gradle-plugin")).with(project(":")) } }

[PHP] Detect User Client IP (XAMPP or Localhost Machine Supported)

Usage: var_dump(get_client_ip()); /** * Detect is localhost * * @return boolean */ function isLocalHost() { $whitelist = [ '127.0.0.1', '::1', ]; return in_array($_SERVER['REMOTE_ADDR'], $whitelist); } /** * Get client ip, when getenv supported (maybe cli) * * @return string */ function get_client_ip() { $ipaddress = ''; if (isLocalHost()) { $ipaddress = getLocalIp(); } else { if (getenv('HTTP_CLIENT_IP')) { $ipaddress = getenv('HTTP_CLIENT_IP'); } elseif (getenv('HTTP_X_FORWARDED_FOR')) { $ipaddress = getenv('HTTP_X_FORWARDED_FOR'); } elseif (getenv('HTTP_X_FORWARDED')) { $ipaddress = getenv('HTTP_X_FORWARDED'); } elseif (getenv('HTTP_FORWARDED_FOR')) { $ipaddress = getenv('HTTP_FORWARDED_FOR'); } elseif (getenv('HTTP_FORWARDED')) { $ipaddress = getenv('HTTP_FORWARDED'); } elseif (ge

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

[JS][PHP] Regexp for matching URL Pattern

Image
Regexp Pattern Untuk mencocokkan semua jenis URL, kode berikut seharusnya berfungsi: <?php $regex = "((https?|ftp)://)?"; // SCHEME $regex .= "([a-z0-9+!*(),;?&=$_.-]+(:[a-z0-9+!*(),;?&=$_.-]+)?@)?"; // User and Pass $regex .= "([a-z0-9\-\.]*)\.(([a-z]{2,4})|([0-9]{1,3}\.([0-9]{1,3})\.([0-9]{1,3})))"; // Host or IP $regex .= "(:[0-9]{2,5})?"; // Port $regex .= "(/([a-z0-9+$_%-]\.?)+)*/?"; // Path $regex .= "(\?[a-z+&\$_.-][a-z0-9;:@&%=+/$_.-]*)?"; // GET Query $regex .= "(#[a-z_.-][a-z0-9+$%_.-]*)?"; // Anchor ?> Example: correctly way for matching URL <?php if(preg_match("~^$regex$~i", 'www.example.com/etcetc', $m)) var_dump($m); if(preg_match("~^$regex$~i", 'http://www.example.com/etcetc', $m)) var_dump($m); ?> Pattern diatas bisa digunakan di javascript. Bedanya dengan diatas hanya dari segi vari

Cara install heroku CLI di Termux

Image
Heroku adalah platform cloud sebagai layanan (PaaS) yang mendukung beberapa bahasa pemrograman. Heroku, salah satu platform cloud pertama, telah dikembangkan sejak Juni 2007, ketika hanya mendukung bahasa pemrograman Ruby, tetapi sekarang mendukung Java, Node.js, Scala, Clojure, Python, PHP, dan Go. Untuk alasan ini, Heroku dikatakan sebagai platform polyglot karena memungkinkan pengembang membangun, menjalankan, dan menskala aplikasi dengan cara yang sama di semua bahasa. Heroku diakuisisi oleh Salesforce.com pada 2010 sebesar $ 212 juta. Berikut tutorial untuk install Heroku App dan pre-requirements nya: Instalasi PHP di Termux Instalasi Composer di Termux Instalasi Node.js di Termux Instalasi Heroku App CLI di Termux Tahap 1: update & upgrade apt cd $HOME apt update -y apt upgrade -y Tahap 2: install PHP dan Composer cd $HOME apt install php -y php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file