Skip to content

Instantly share code, notes, and snippets.

View gabrieljmj's full-sized avatar
💻
Working from home

Gabriel Jacinto gabrieljmj

💻
Working from home
  • Zig
  • Itajobi, SP, Brazil
View GitHub Profile
@gabrieljmj
gabrieljmj / Session.class.php
Created September 19, 2013 19:28
A helper to work with sessions in php
<?php
class Session{
public static function add( $name, $value ){
$_SESSION[ $name ] = $value;
}
public static function del( $name ){
unset( $_SESSION[ $name ] );
}
@gabrieljmj
gabrieljmj / Converter.class.php
Last active November 22, 2017 12:07
Currency converter using Google API You must have the curl extension in PHP active.
<?php
/**
* @author @GabrielJMJ /twitter
* @description Abstract class to define a interface of a converter
* @link https://gist.github.com/GabrielJMJ/6977968 Gist on GitHub
**/
abstract class Converter{
protected $valueWithCurrency;
protected $toCurrency;
@gabrieljmj
gabrieljmj / extern-request.php
Created October 15, 2013 18:41
Verify if exists an extern request
<?php
if( isset( $_SERVER['HTTP_REFERER'] ) and !stristr( $_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'] ) ){
//...
}
@gabrieljmj
gabrieljmj / example.php
Last active August 29, 2015 14:08
Solving Quadratic Formula with Bhaskara
<?php
print_r(quadEq(1, 2, 1));// a=1 b=2 c=3 (x² + 2x + 3 = 0)
//Result: array(-1)
$images = array(
1 => 'https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcSwN2pF0jnnNlxtNRythauTtBgtNFTSx0ucRHeKfahoo33XEtFjUEYVfnE',
2 => 'http://i7.photobucket.com/albums/y266/Linkforce712/SEA01.png'
);
$arr = array(1, 1, 1, 1, 1, 1);
$arr2 = array(1, 2, 2, 2, 2, 1);
$arr3 = array(1, 1, 1, 1, 1);
function transform($images)
@gabrieljmj
gabrieljmj / README.md
Last active August 29, 2015 14:14
Why numbering should start at one - representation class PHP
@gabrieljmj
gabrieljmj / HideStaticMethods.php
Last active August 29, 2015 14:15
Hidding static methods
<?php
namespace Gabrieljmj;
trait HideStaticMethods
{
public function __call($method, $args)
{
return foward_static_call_array(array(self, $method), $args);
}
}
@gabrieljmj
gabrieljmj / Environment.php
Created February 17, 2015 23:20
Simple Should port for PHP - complete framework https://github.com/GabrielJMJ/ShouldPHP
<?php
class Environment
{
private $shouldState;
private $verbs = array('be', 'have');
private $toTest;
public function __construct($toTest, $shouldState = false, $verb = null)
{
$this->toTest = $toTest;
@gabrieljmj
gabrieljmj / eg.js
Last active July 20, 2023 08:21
Psr4 implementation NodeJS
psr4.add('Gabrieljmj\\Blog\\', 'modules/gabrieljmj/blog/');
psr4.add('Gabrieljmj\\Blog\\Controller\\', 'modules/gabrieljmj/blog/constrollers/');
var postsController = psr4.use('Gabrieljmj\\Blog\\Posts'); //require('modules/gabrieljmj/blog/Posts')
var postsController = psr4.use('Gabrieljmj\\Blog\\Controller\\Posts'); //require('modules/gabrieljmj/blog/controllers/posts')
@gabrieljmj
gabrieljmj / README.md
Last active August 29, 2015 14:19
Solving math problems