Skip to content

Instantly share code, notes, and snippets.

@lighta971
lighta971 / db_backup.php
Created June 27, 2014 22:07
PHP (large) DB backup
<?php
$DBHOST="host";
$DBUSER="user";
$DBPASSWD="pass";
$DATABASE="db";
$filename = "backup-" . date("d-m-Y") . ".sql.gz";
$mime = "application/x-gzip";
@lighta971
lighta971 / phpmyadmin.sh
Created May 26, 2014 09:38
Install latest phpmyadmin on ubuntu
sudo add-apt-repository ppa:tuxpoldo/phpmyadmin
sudo apt-get update
sudo apt-get install phpmyadmin
@lighta971
lighta971 / remove_matched_files.sh
Created May 22, 2014 09:17
remove files from find pattern
find . -name 'pattern' | xargs rm -f
@lighta971
lighta971 / change_user_group.sh
Created May 21, 2014 18:58
Change user group on FreeBSD
pw user mod myname -G wheel
@lighta971
lighta971 / pivot_example.php
Created May 9, 2014 15:03
Laravel Custom Pivot Model definition example
<?php
//https://github.com/laravel/framework/issues/2093#issuecomment-39154456
use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Database\Eloquent\Relations\Pivot;
class User extends Eloquent {
public function groups() {
return $this->belongsToMany('Group');
@lighta971
lighta971 / phpmyadmin_installation_for_mysqlnd.md
Last active May 2, 2016 10:19
Install phpmyadmin 3.4.10.1 for mysqlnd

Installation of Phpmyadmin 3.4.10.1 with mysqlnd for Debian based OS##

Assuming php5-mysqlnd is already installed.

1) Download phpmyadmin deb package:

 apt-get download phpmyadmin
#!/bin/bash
# usage: save as 'videbcontrol.sh'; chmod 755 videbcontrol.sh; ./videbcontrol.sh foo.deb
#
# from: http://ubuntuforums.org/showthread.php?t=636724
if [[ -z "$1" ]]; then
echo "Syntax: $0 debfile"
exit 1
fi
#subdomain name
echo -n "Name of your subdomain ?"
read -e subdomain
if [[ $subdomain != "" ]]
then
mkdir ~/$subdomain
sudo touch /etc/apache2/sites-available/$subdomain
sudo echo "<Virtualhost *:80>" >> /etc/apache2/sites-available/$subdomain
sudo echo " ServerName $subdomain.username.kd.io" >> /etc/apache2/sites-available/$subdomain
@lighta971
lighta971 / flashDetector.js
Created December 27, 2013 19:00
Detect Flash enable in browser
try {
if( new ActiveXObject('ShockwaveFlash.ShockwaveFlash') ) flash = true;
}catch(e){
if(navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) flash = true;
}
@lighta971
lighta971 / pop.js
Last active January 1, 2016 09:19
Open popup every x hours
function _pop(url) {
var e = {};
e.width = e.width || screen.width;
e.height = e.height || screen.height;
var t = "width=" + e.width + "px,height=" + e.height + "px,top=" + (screen.height - e.height) / 2 + ",left=" + (screen.width - e.width) / 2 + ",resizable=no,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no";
var n = window.open("about:blank", "_blank", t, false);
n.document.location.href = url;
}