Skip to content

Instantly share code, notes, and snippets.

View igoralves1's full-sized avatar

Igor Alves igoralves1

View GitHub Profile
private function tool_save_File($str, $filePathNameExtention) {
$myfile = fopen("$filePathNameExtention", "w") or die("Unable to open file!");
fwrite($myfile, $str);
fclose($myfile);
}
@igoralves1
igoralves1 / gist:9be2cdab5623bf790e590b69d0d12ef2
Last active April 13, 2016 20:07
PHP - Filter a string to be saved in the MySql database
private function tool_string_filter($str) {
if(is_null($str)){
return "NULL";
}
else{
if(is_numeric ($str)){
return $str;
}
else{
return "\"".mysql_escape_string(utf8_encode($str))."\"";
public function genetare_XML_string(array $arrSetOrder) {
//Values by default
$arrIni["Object"]=17;
$arrIni["Version"]=2;
$arrIni["Company"]="US";//Default is not demo Company
//Setting user's parameters
$arrOrder = array_merge($arrIni,$arrSetOrder);
@igoralves1
igoralves1 / gist:b0ff06357da944ee93e0f8b56e926b2c
Last active April 15, 2016 03:37
PHP - Filter empty spaces, or /n (new lines) in HTML strings
//This is a good aproach to send HTML strings trough JSON.
//As the new lines or empty spaces are removed, JSON will not be broked.
function html_rows_Event_Details() {
$str =<<<eof
<tr class='evntdet'>
<td colspan='4' style='background-color:#00BABF ; padding: 10px; text-align: center;'>
Something
</td>
@igoralves1
igoralves1 / gist:91120405b9cf011713421456e81ec003
Last active April 19, 2016 12:29
JS - Select <tr> - Traversing DOM
Selecionando elemento de uma linha na tabela A, muda o comprtamento de linhas selecionadas em outras tabelas, inclusive a A.
https://jsfiddle.net/aj1p62bz/
//Html
<table style='width:50% ;height:50%;border: 3px solid #00BABF;border-collapse: collapse;' align='center'>
<tr class="rowProducts" id="rowPrd">
<td>
<table >
<tr>
<td>Jill</td>
@igoralves1
igoralves1 / gist:6b69fe0d630a1ecce7160e380c16d205
Created April 19, 2016 13:44
JS - GOOGLE API - Redirect User to different Website Based on Location (IP Address)
//http://jsfiddle.net/kvishnudev/7Ut65/1/
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
@igoralves1
igoralves1 / gist:b2d9c7e3ed335309afbffcadbcfe68cb
Created April 19, 2016 14:09
PHP - Remove an array element in a loop? Remover um elemento da array a cada ciclo do loop.
$arr1v=Array
(
"2016-04-11 17:16:59"=> "2016-04-11 17:16:59",
"2016-04-14 16:47:18"=> "2016-04-14 16:47:18",
"2016-04-14 15:39:30" => "2016-04-14 15:39:30",
"2016-04-12 15:35:46" => "2016-04-12 15:35:46",
'2016-04-14 15:31:43'=> "2016-04-14 15:31:43",
'2016-04-14 15:27:10'=> "2016-04-14 15:27:10",
'2016-04-14 14:59:45' => '2016-04-14 14:59:45',
'2016-04-15 13:41:22'=> '2016-04-15 13:41:22',
@igoralves1
igoralves1 / gist:4a3d388f91e2c498e96020a9d87b5146
Created April 20, 2016 19:23
PHP - Data base Object. PDO - Mysql
/**
* Em desenvolvimento.
* Objeto para gerenciar uma
*conexão ao banco de dados Mysql
* @author Igor
*/
class db {
private $dsn;
private $username;
private $password;
$(function() {
timeout = setTimeout(function() {
window.location.href = "http://google.com";
}, 2500);//waiting 2,5s
});
$(document).on('mousemove', function() {
if (timeout !== null) {
clearTimeout(timeout);
}
@igoralves1
igoralves1 / gist:82b7ff09632fcb9916a31842533f6bf6
Last active April 21, 2016 14:12
PHP - Read xml and return a php array. Deal with date formating.
/*
This function goes to the directory $pathDir, pass trough each all files inside it,
seeks for any file that math to the $searchString and reads it.
Return the content of all matched xml files within a php Array.
Ex:
We have inside the FTP the follow files genereted by a CronJob:
fileCarAudiRent2015.xml, fileCarAudiRent2016.xml, fileCarAudiSell2015.xm,
fileCarBMWRent2015.xml, fileCarBMWSell2016.xml, fileBoatWMBRent2015.xml, fileBoatWMBSell2015.xml,
fileBoatAudiRent2015.xml, fileBoatAudiSell2016.xml, ... .