Skip to content

Instantly share code, notes, and snippets.

View earvinpiamonte's full-sized avatar

Noel Earvin Piamonte earvinpiamonte

  • Infor
  • Baguio City, Philippines
View GitHub Profile
@earvinpiamonte
earvinpiamonte / delete-multiple-branch-having-the-same-prefix-in-a-single-command.sh
Last active August 15, 2019 03:17
Delete multiple branch having the same prefix in a single command - Git
git branch -d `git branch --list 'YOUR-BRANCH-PREFIX-*'`
# or
# git branch -D `git branch --list 'YOUR-BRANCH-PREFIX-*'`
@earvinpiamonte
earvinpiamonte / .htaccess
Created September 1, 2019 04:55
Codeigniter .htaccess - force HTTPS
RewriteEngine On
# start force http www (optional)
RewriteCond %{HTTP_HOST} !=localhost
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# end force http www (optional)
# start force https
RewriteCond %{HTTP_HOST} !=localhost
@earvinpiamonte
earvinpiamonte / .htaccess
Created September 1, 2019 04:55
Manually force to HTTPS for Apache
# Note: Replace "example.com" with your own domain.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
@earvinpiamonte
earvinpiamonte / loop-through-numeric-representation-of-months-with-leading-zeros-in-php.php
Created September 1, 2019 04:56
Loop through numeric representation of months, with leading zeros in PHP
<?php
// get current timestamp
$timestamp = time();
// get full numeric representation of a year, 4 digits
$current_year = date('Y', $timestamp);
// maximum number of months to display
$max_monhts = 12;
@earvinpiamonte
earvinpiamonte / paypal-client-authentication-failed-fix.php
Created September 1, 2019 04:56
PayPal: Client Authentication failed fix
<?php
//
// Assuming you already installed paypal/rest-api-sdk-php
// https://github.com/paypal/PayPal-PHP-SDK/wiki/Installation
//
// Autoload SDK package
// if using composer
@earvinpiamonte
earvinpiamonte / display-current-date-time.php
Created September 1, 2019 04:57
Display user's local time using PHP (client side)
// date time from server side
// echo date('Y-m-d H:i:s', time());
// date time from client side
echo '<script type="text/javascript">
var d = new Date();
document.write(d.getFullYear()+"-"+("0"+(d.getMonth() + 1)).slice(-2)+"-"+("0"+d.getDate()).slice(-2)+" "+("0"+d.getHours()).slice(-2)+":"+("0"+d.getMinutes()).slice(-2)+":"+("0"+d.getSeconds()).slice(-2));
</script>';
@earvinpiamonte
earvinpiamonte / get_discounted_price_in_php.php
Created September 1, 2019 04:58
Get discounted price in PHP
<?php
$original_price = 25.90;
$discount_percentage = 4;
$discount_decimal = ($discount_percentage / 100);
$discount_price = $discount_decimal * $original_price;
@earvinpiamonte
earvinpiamonte / .htaccess
Created September 1, 2019 04:59
Codeigniter redirect without index.php using .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
@earvinpiamonte
earvinpiamonte / add_linux_user_to_www_data_group.bash
Last active September 2, 2019 14:39
Add Linux user to www-data group. Fix unable to edit files under /var/www/html/
# Add the current user to www-data group
sudo usermod -a -G www-data $USER
# Change the group of web server directory to www-data
sudo chgrp -R www-data /var/www/html
# Give write permission to the www-data group
sudo chmod -R g+w /var/www/html
@earvinpiamonte
earvinpiamonte / eg-virtual-host-file.conf
Created September 8, 2019 05:23
Eg. virtual host file
<VirtualHost 127.0.1.2:80>
ServerName laravel-app
DocumentRoot /var/www/html/laravel-app
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html/laravel-app>
Options All
AllowOverride All