Skip to content

Instantly share code, notes, and snippets.

View fhferreira's full-sized avatar
🏠
Home-Office since 2005

Flávio H. Ferreira fhferreira

🏠
Home-Office since 2005
View GitHub Profile
@fhferreira
fhferreira / GeneratePassword.php
Last active December 27, 2015 11:19
Generate Password
<?php
function GeneratePassword($length,$caracteres){
$password = "";
$length_c = strlen($caracteres);
while(strlen($password) < $length){
$pos = rand( 0 , $length_c - 1 );
$password .= $caracteres[$pos];
}
return $password;
@fhferreira
fhferreira / devbus.js
Last active December 27, 2015 13:39
DevBus
dev = 0;
bus = 0;
devbus = 0;
for(i=1;i<101;i++){
if(i%3 == 0 && i%5 == 0){
document.write( i + ' - devbus<br/>');
devbus++;
}
if(i%3 == 0){
document.write( i + ' - dev<br/>');
@fhferreira
fhferreira / getURLFull.php
Last active December 27, 2015 16:09
Capturar URL completa
<?php
function getURLFull() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
<?php
// Inicio do arquivo omitido
/*
* Detectar domínio no Laravel 4.1 e aplicar o ambiente correspondente
*/
$env = $app->detectEnvironment(function(){
<?php
/*
|--------------------------------------------------------------------------
| Delete form macro
|--------------------------------------------------------------------------
|
| This macro creates a form with only a submit button.
| We'll use it to generate forms that will post to a certain url with the DELETE method,
| following REST principles.
@fhferreira
fhferreira / routes.php
Created January 9, 2014 00:09
View Composer with Paginator add Query String parameters
<?php
View::composer(Paginator::getViewName(), function($view) {
$query = array_except( Input::query(), Paginator::getPageName() );
$view->paginator->appends($query);
});
<?php namespace Fhferreira\Zodiac;
//File: workbench\fhferreira\zodiac\src\Fhferreira\Zodiac\Zodiac.php
class Zodiac{
/**
* @var \DateTime
*/
protected $date;
/**
@fhferreira
fhferreira / getQuery.php
Last active January 2, 2016 18:19
Last QUery or All Query's Laravel 4
<?php
//Last Queries
$queries = DB::getQueryLog();
$last_query = end($queries);
dd($last_query);
//or All Queries
$queries = DB::getQueryLog();
dd($queries);
//or All Queries and bindings in the string
$queries = DB::getQueryLog();
@fhferreira
fhferreira / calculateAge.php
Last active January 3, 2016 04:49
Calcular Idade com PHP
<?php
function calcutateAge($birthday){
$birthday = date("Y-m-d",strtotime($birthday));
$birthdayObject = new DateTime(birthday);
$nowObject = new DateTime();
$diff = $birthdayObject->diff($nowObject);
<?php
function palindromes($words) {
$str = "";
// Write your code here
foreach($words as $word){
if( $word == strrev($word) ){
$str .= 'T';
}else{
$str .= 'F';
}