Skip to content

Instantly share code, notes, and snippets.

View gravataLonga's full-sized avatar
🤓
Zig Nerding

Jonathan Fontes gravataLonga

🤓
Zig Nerding
View GitHub Profile
alert('Jonathan');
@gravataLonga
gravataLonga / interface
Last active August 29, 2015 14:14
/etc/network/interface
auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
wpa-ssid "XXXXXXXXXXX"
<?php
define ("SERIAL_DEVICE_NOTSET", 0);
define ("SERIAL_DEVICE_SET", 1);
define ("SERIAL_DEVICE_OPENED", 2);
/**
* Serial port control class
*
* THIS PROGRAM COMES WITH ABSOLUTELY NO WARANTIES !
* USE IT AT YOUR OWN RISKS !
@gravataLonga
gravataLonga / overlapdate.txt
Created January 28, 2015 14:45
Overlap Date Range
(StartDate1 <= EndDate2) and (StartDate2 <= EndDate1)
@gravataLonga
gravataLonga / output.php
Last active April 28, 2017 19:30
output cli function
<?php
function output ( $str, $tabs = 0, $date = TRUE, $silent = FALSE )
{
// Silent echo's
if( !empty($silent))
{
return FALSE;
}
if( is_array($str))
function emptySet(x) {
return false;
}
function insert(elem, set) {
return function(x) {
if (x === elem) { // insert smarter comparison here if needed
return true;
}
return function() { return contains(x, set); };
<?php
/* ---------------------------------------------------------- */
/* minibots.class.php Ver.1.9g */
/* ---------------------------------------------------------- */
/* Mini Bots class is a small php class that allows you to */
/* use some free web seriveces online to retrive usefull data */
/* and infos. This version includes: */
/* smtp validation, check spelling, meteo, exchange rates, */
/* shorten urls, and geo referencing with IP address and more */
/* Feel free to use in your applications, but link my blog: */
@gravataLonga
gravataLonga / cleanUrl.php
Last active April 9, 2016 14:38
Clean URL
<?php
function cleanForShortURL($toClean) {
$charactersToRemove = array(
'Š'=>'S', 'š'=>'s', 'Ð'=>'Dj','Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A',
'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E', 'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I',
'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U', 'Ú'=>'U',
'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss','à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a',
'å'=>'a', 'æ'=>'a', 'ç'=>'c', 'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i',
@gravataLonga
gravataLonga / Exception
Created November 1, 2013 11:45
Exception php
<?php
interface IException
{
/* Protected methods inherited from Exception class */
public function getMessage(); // Exception message
public function getCode(); // User-defined Exception code
public function getFile(); // Source filename
public function getLine(); // Source line
public function getTrace(); // An array of the backtrace()
public function getTraceAsString(); // Formated string of trace
@gravataLonga
gravataLonga / genPassword.php
Last active April 9, 2016 14:38
Generate a random Password
<?php
function generatePassword ($length = 8) {
$password = "";
$possible = "2346789bcdfghjkmnpqrtvwxyzBCDFGHJKLMNPQRTVWXYZ";
$maxlength = strlen($possible);
// check for length overflow and truncate if necessary
if ($length > $maxlength) {
$length = $maxlength;