Skip to content

Instantly share code, notes, and snippets.

View vubon's full-sized avatar
🎯
Focusing

Vubon vubon

🎯
Focusing
View GitHub Profile
//Add in text after price to all products
function custom_text_to_price( $price, $product ) {
$price = $price . ' USD';
return $price;
}
add_filter( 'woocommerce_get_price_html', 'custom_text_to_price', 100, 2 );
@vubon
vubon / postgres
Created December 14, 2017 08:40 — forked from mmrwoods/postgres
Postgres maintenance crontab file
# dump all databases once every 24 hours
45 4 * * * root nice -n 19 su - postgres -c "pg_dumpall --clean" | gzip -9 > /var/local/backup/postgres/postgres_all.sql.gz
# vacuum all databases every night (full vacuum on Sunday night, lazy vacuum every other night)
45 3 * * 0 root nice -n 19 su - postgres -c "vacuumdb --all --full --analyze"
45 3 * * 1-6 root nice -n 19 su - postgres -c "vacuumdb --all --analyze --quiet"
# re-index all databases once a week
0 3 * * 0 root nice -n 19 su - postgres -c 'psql -t -c "select datname from pg_database order by datname;" | xargs -n 1 -I"{}" -- psql -U postgres {} -c "reindex database {};"'
@vubon
vubon / response.py
Created December 3, 2017 05:01
Checking Rest API Response Time
"""
This script will check server response time in seconds.
"""
import requests
while True:
a = requests.get("your api url").elapsed.total_seconds()
print(a)
@vubon
vubon / form.php
Created September 24, 2017 16:02
WordPress post password form customization
// Your page content display by this code
<?php if ( !post_password_required() ) { ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
<?php } ?>
@vubon
vubon / form.php
Created September 24, 2017 16:02
WordPress post password form customization
// Your page content display by this code
<?php if ( !post_password_required() ) { ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
<?php } ?>
@vubon
vubon / Insert csv data PostgreSQL database by Python.txt
Last active January 1, 2018 14:51
Insert csv data PostgreSQL database by Python
Firstly import below modules in Python file or Django file .
1. csv
2. psycopg2
Now Firstly create a connection with your database below way
try:
conn_string="dbname='user database name' user='database user name' host='localhost' password='your user password'"
print ("Connecting to database\n->%s" % (conn_string))
conn = psycopg2.connect(conn_string)
print ("connection succeeded")
except:
@vubon
vubon / terminal.txt
Created June 13, 2017 05:15
File copy or Folder copy by Terminal from Remote server
Firstly You need to open your terminal then login
scp -r ursername@hostname:/path of your file or folder /home/where you want to save the folder or file
This command copy your file from remote server .
now if you want to send a file in your server then you can write down below command
scp -r /home/where you want to save the folder or file ursername@hostname:/path of your file or folder
@vubon
vubon / xampp.txt
Created June 6, 2017 09:15
Install New version xampp in your Ubuntu machine
First go to here https://www.apachefriends.org/download.html
Now copy the url
You will get the URL like this
https://www.apachefriends.org/xampp-files/7.1.4/xampp-linux-x64-7.1.4-0-installer.run
Now open your terminal and run the following command
wget https://www.apachefriends.org/xampp-files/7.1.4/xampp-linux-x64-7.1.4-0-installer.run
After that run this
@vubon
vubon / ReadMe.txt
Last active January 8, 2019 16:14
Install PostgreSQL in Ubuntu 16.04
#Update your apps by below command and install
$ sudo apt-get update
$ sudo apt-get install postgresql postgresql-contrib
#Connect to PostgreSQL
$ sudo su - postgres
$ psql
#Checking connection with user information
@vubon
vubon / ADB.txt
Created January 17, 2017 19:15
Manually adding Android ADB USB driver in Ubuntu 16.04 LTS
Requirements:
Operating System: Ubuntu 16.04 LTS
Android Developer Tools (ADT) installed
Steps:
Make sure that you have connected your Android device in USB Debugging mode
Press Ctrl + Alt + T for Terminal and use the following command:
lsusb