Skip to content

Instantly share code, notes, and snippets.

View rbhushan90's full-sized avatar

Ravi Bhushan rbhushan90

View GitHub Profile
<script type="text/javascript" src="https://dobermandan.iljmp.com/improvely.js"></script>
<script type="text/javascript">
improvely.init('dobermandan', 1);
improvely.conversion({
goal: 'sale',
revenue: <?php echo $_POST['Total']; ?>,
reference: '<?php echo $_POST['orderID']; ?>'
});
</script>
@rbhushan90
rbhushan90 / mysqldb_python3.sh
Created April 10, 2019 15:44 — forked from shibli049/mysqldb_python3.sh
Install mysqlclient for python3
#sudo pip3 install mysqlclient fails with mysql_config not found
sudo apt-get install libmysqlclient-dev
#without pip3 it will not going to work for python3
sudo pip3 install mysqlclient
# to run django migration
python3 manage.py migrate
@rbhushan90
rbhushan90 / db_backup.sh
Created July 21, 2018 11:51 — forked from NARKOZ/db_backup.sh
MySQL backup shell script
#!/bin/bash
# Shell script to backup MySQL database
# Set these variables
MyUSER="" # DB_USERNAME
MyPASS="" # DB_PASSWORD
MyHOST="" # DB_HOSTNAME
# Backup Dest directory
DEST="" # /home/username/backups/DB
@rbhushan90
rbhushan90 / gist:3724b64f803d9f37f089a92ae49683d5
Created May 27, 2018 09:13 — forked from ankitnetwork18/gist:4509792
mysql: dump of indian cities and states
-- phpMyAdmin SQL Dump
-- version 2.11.6
-- http://www.phpmyadmin.net
--
-- Host: localhost:3306
-- Generation Time: Jan 11, 2013 at 04:24 PM
-- Server version: 5.0.51
-- PHP Version: 5.2.5
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
http://www.mysqltutorial.org/import-csv-file-mysql-table/
------------------------------------------------------------
Import CSV File Into MySQL Table
This tutorial shows you how to use the LOAD DATA INFILE statement to import CSV file into MySQL table.
DBNAME=<database_name>
TABLE=<table_name>
FNAME=/path/to/output/dir/$(date +%Y.%m.%d)-$DBNAME.csv
#(1)creates empty file and sets up column names using the information_schema
mysql -u <username> -p<password> $DBNAME -B -e "SELECT COLUMN_NAME FROM information_schema.COLUMNS C WHERE table_name = '$TABLE';" | awk '{print $1}' | grep -iv ^COLUMN_NAME$ | sed 's/^/"/g;s/$/"/g' | tr '\n' ',' > $FNAME
#(2)appends newline to mark beginning of data vs. column titles
echo "" >> $FNAME
@rbhushan90
rbhushan90 / mysql-export-import
Created April 8, 2017 04:27 — forked from el22or/mysql-export-import
Remote MySQL database dump directly into local database
## SSH - Remote export > local import
ssh USER@HOST mysqldump -uREMOTEDATABASEUSER -pREMOTEDATABASEPASSWORD -hREMOTEHOST REMOTEDATABASENAME | mysql -uLOCALDATABASEUSER -pLOCALDATABASEPASSWORD LOCALDATABASENAME
## Export to CSV
mysql -uUSER -pPASS DATABASENAME -B -e "select * from \`korisnici\`;" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > filename.csv
## Export to CSV 2
mysql -uUSER -pPASS DATABASE -B -e "SELECT users.uid AS 'ID', users.name AS 'Username', users.mail AS 'Email', from_unixtime(users.created) AS 'Created', from_unixtime(users.login) AS 'Last login' FROM users WHERE users.status=1 AND users.login!=0 ORDER BY users.login DESC;" | sed "s/'/\'/;s/\t/\",\"/g;s/^/\"/;s/$/\"/;s/\n//g" > vehicle_categories.csv
## Export to SQL gzipped file with compression
@rbhushan90
rbhushan90 / html_attr_extraction_functions.php
Created October 18, 2016 00:17 — forked from thepsion5/html_attr_extraction_functions.php
Simple PHP functions to extract links and metadata from a webpage
<?php
//Created as an alternative to an article demonstrating the use of regular expressions to parse HTML:
// http://www.web-development-blog.com/archives/parse-html-with-preg_match_all/
/**
* @param string $remoteUrl
* @param string $yourLink
* @return bool
*/
function check_back_link($remoteUrl, $yourLink)
@rbhushan90
rbhushan90 / gist:eb7d4ad6045caad9025d0b8da27579c8
Created July 20, 2016 09:23 — forked from barlino/gist:2964314
PHP – Generate/Create strong passwords, uuid, random string
//The code is from http://www.mcgarvie.net/2009/07/17/programming/php/php-generatecreate-strong-passwords-uuid-random-string made by Brian M McGarvie/
/**
Perfect for: PASSWORD GENERATION
Options: variable length
generateRandStr(8)
result: 4sRBfahW
**/
<?php