Skip to content

Instantly share code, notes, and snippets.

@lighta971
lighta971 / Program.cs
Last active December 31, 2015 10:49
C# Resolve Gateway MAC from public ip addr. Thanks to Stackoverflow community
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Arp
<?php
/**
*
* Thanks to Erickson Reyes ercbluemonday at yahoo dot com | so processes dont overlap
* ref : http://www.php.net/manual/en/function.getmypid.php#94531*/
// Initialize variables
$found = 0;
$file = basename(__FILE__);
$commands = array();
@lighta971
lighta971 / gist:8054510
Created December 20, 2013 13:02
Laravel bootstrap
#------------------Set tinker config for Boris (Laravel 4.1>=)
#Go to cli php.ini (php --ini)
#remove all disable_functions
#reload apache "servce apache2 reload"
#-----------------Install clockwork for debugging
# https://github.com/itsgoingd/clockwork
@lighta971
lighta971 / helpers.php
Created December 20, 2013 13:07
Laravel Menu active state helper Add to composer.json: "autoload": { "files": ["app/helpers.php"] } Then run "composer dump" #http://paste.laravel.com/1acS
// helper
function set_active($path, $active = 'active') {
return call_user_func_array('Request::is', (array)$path) ? $active : '';
}
// usage in view
<li class="{{ set_active(['admin/institutes*','admin/courses*']) }}">
@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;
}
@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;
}
#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
#!/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
@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
@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');