Skip to content

Instantly share code, notes, and snippets.

View innbitcodes's full-sized avatar

InnBit Codes innbitcodes

View GitHub Profile
@innbitcodes
innbitcodes / Git upgrade script in Ubuntu
Created February 17, 2015 18:02
Bash: upgrade git to latest version
// Install add-apt-repository
sudo apt-get install python-software-properties
sudo apt-get install software-properties-common
// Add ppa to current software repository
sudo add-apt-repository ppa:git-core/ppa -y
sudo apt-get update
sudo apt-get install git
git --version
@innbitcodes
innbitcodes / PHP: 301 redirect
Created August 30, 2014 20:27
301 redirect by PHP header code
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.-----.com");
?>
@innbitcodes
innbitcodes / Bash: Install vcprompt
Created January 9, 2014 20:32
vcprompt installation in Terminal command line
cd; mkdir ~/bin && curl -sL https://github.com/djl/vcprompt/raw/master/bin/vcprompt > ~/bin/vcprompt && chmod 755 ~/bin/vcprompt && sudo mv ~/bin/vcprompt /bin/vcprompt && sudo rm -rf ~/bin
@innbitcodes
innbitcodes / Ubuntu: SDK Installation
Created January 8, 2014 18:15
Ubuntu SDK installation commands
// Ubuntu 12.04 LTS, 12.10, 13.04 and 13.10
sudo add-apt-repository ppa:ubuntu-sdk-team/ppa && sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get install ubuntu-sdk
// Ubuntu development release
sudo apt-get update && sudo apt-get install ubuntu-sdk
@innbitcodes
innbitcodes / Apache: remove virtual host
Created January 7, 2014 13:57
Remove virtual host from Apache server
sudo a2dissite sitename
sudo /etc/init.d/apache2 reload
sudo rm /etc/apache2/sites-available/sitename
@innbitcodes
innbitcodes / PHP: connect to MySQL with PDO
Created January 5, 2014 10:14
Way to connect MySQL with PDO method in PHP
<?php
try{
$db = new PDO("mysql:host=HOST_NAME;dbname=DB_NAME;port=PORT_NUM", "USER", "PASS");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->exec("SET NAMES 'utf8'");
} catch (Exception $e) {
echo "Could not connect to database.";
exit;
}
@innbitcodes
innbitcodes / Customization for .bashrc
Created January 3, 2014 05:55
Bash Prompt Customization Code
export PATH=~/bin:$PATH
txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
txtwht='\e[0;37m' # White
@innbitcodes
innbitcodes / Get query string value from URL
Created December 26, 2013 09:34
Demostration of getting query string values from URL
<script>
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&amp;");
for (var i=0;i&lt;vars.length;i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
@innbitcodes
innbitcodes / MySQL: Create DB in UTF8
Last active October 12, 2017 21:20
MySQL: Create Database in UTF8
CREATE DATABASE dbname DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON dbname.* TO 'dbuser' IDENTIFIED BY 'dbpassword';
flush privileges;
@innbitcodes
innbitcodes / maximage-generic.js
Created November 3, 2012 06:40 — forked from akv2/maximage-generic.js
jQuery: Generic settings for maximage demo.
$(function(){
$('#maximage').maximage({
cycleOptions: {
fx: 'fade',
// Speed has to match the speed for CSS transitions
speed: 1000,
timeout: 0,
prev: '#arrow_left',
next: '#arrow_right',
pause: 1