Skip to content

Instantly share code, notes, and snippets.

View ethaizone's full-sized avatar
💭
It's same on Gitlab.

Nimit Suwannagate ethaizone

💭
It's same on Gitlab.
View GitHub Profile
@ethaizone
ethaizone / getGitStatus.php
Last active August 29, 2015 14:13
Add new logic for git that deploy via jenkin (multi-scm) and add as original code that I use on Laravel
<?php
/**
* Get Git Status via PHP (No execute function)
* @author Nimit Suwannagate <ethaizone@hotmail.com>
* Laravel Version
*/
function getGitStatus()
{
$branch = null;
@ethaizone
ethaizone / helper-view.php
Created January 26, 2015 14:31
Example view render as helper
<?php
if (! function_exists('view'))
{
/**
* Render view as html with layout system
* @author Nimit Suwannagate <ethaizone@hotmail.com>
*/
function view($viewName, $data = array(), $layout = 'default')
{
@ethaizone
ethaizone / helper-web-path.php
Created January 26, 2015 14:35
Lazy method but work - Helper for get baseUrl and basePath for website/webapp development
<?php
if ( ! function_exists('basePath'))
{
/**
* Get the path to the base of the install.
*
* @param string $path
* @return string
*/
@ethaizone
ethaizone / dq.php
Created March 24, 2015 07:36
Simple laravel helper - Dump Query
<?php
// write by me.
if ( ! function_exists('dq'))
{
function dq($offset = 0, $length = null, $echoOnly = false)
{
s(array_slice(DB::getQueryLog(), $offset, $length));
if ($echoOnly == false)
@ethaizone
ethaizone / date_thai_helper.php
Last active October 1, 2015 11:08
Date in Thai
<?php
/**
* Date function for Thai
* Lazy code version.
*
* Don't remove copyright.
*
* @author Nimit Suwannagate <ethaizone@hotmail.com>
*/
@ethaizone
ethaizone / ProductControllerTest.php
Last active November 24, 2015 17:08
Laravel 5.1 - Run testcase with real model in memory.
<?php
use Illuminate\Foundation\Testing\DatabaseMigrations;
class ProductControllerTest extends TestCase
{
use DatabaseMigrations;
protected $testSubject = null;
@ethaizone
ethaizone / SoftBelongsToMany.php
Last active January 3, 2016 11:09
When I want to store pivot data in pivot table. When I detach, record will delete so this can make pivot table can do soft delete. #Laravel4 #relation #belongsToMany
<?php
/**
* write by EThaiZone <ethaizone@hotmail.com>
* todo feature - about update data of pivot table
*/
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
@ethaizone
ethaizone / test_math_random_possible.js
Created March 8, 2016 09:03
Test Math.random() result.
var res = {0:0,1:0};
var r;
for(var i = 0; i < 100; i++) {
r = Math.floor((Math.random() * 2) + 0);
res[r]++;
}
console.log(res);
<?php
use Redis;
use Exception;
/**
* Redis cache - Port from Phalcon Cache
* Cut intergate from backend and front cache
* I don't test or try run it. This pass on php linter.
* When I want to use it, I will check later.
@ethaizone
ethaizone / custom_base_converter.php
Created May 17, 2016 11:05
Custom base number converter.
<?php
/**
* Code demo for convert base number with custom base character map.
* Not support negative number.
*/
// base from toHex on http://hashids.org/
function intToChar($input)
{