Skip to content

Instantly share code, notes, and snippets.

View sunspikes's full-sized avatar

Krishnaprasad MG sunspikes

View GitHub Profile
@sunspikes
sunspikes / PaginationAdapterTrait.php
Created November 23, 2018 11:26
Doctrine -> Zend Pagination adapter
<?php
namespace ApiCore\Adapter;
use Doctrine\ORM\Query;
use Zend\Paginator\Adapter\AdapterInterface;
class PaginationAdapterTrait
{
public function getAdapterFromQuery(Query $query)
@sunspikes
sunspikes / jobs.php
Created July 24, 2018 07:17
Jobvites API proxy
<?php
$api = '*_jobfeedapi_key';
$key = 'KEY';
$url = 'https://api.jobvite.com/api/v2/job?api=' . $api . '&sc=' . $key;
$cacheFile = 'jobs.data.json';
$versionFile = 'jobs.version.txt';
header('Content-Type: application/json;charset=utf-8');
@sunspikes
sunspikes / docker-compose.yml
Created April 27, 2018 09:09
PHP-MySQL Dev Docker
version: '3'
services:
db:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test
MYSQL_USER: devuser
MYSQL_PASSWORD: devpass
@sunspikes
sunspikes / csv2Caml.php
Created February 23, 2018 16:20
csv2Caml convertor
<?php
setlocale(LC_ALL, 'de_DE.utf8');
ini_set('auto_detect_line_endings', true);
set_error_handler(function ($errNo, $errStr) { throw new \ErrorException($errStr, $errNo); });
$ibanDir = '.'.DIRECTORY_SEPARATOR.'iban';
$users = [];
$count = 0;
$totalAmount = 0;
<?php
namespace Level1 {
function foo($x)
{
return $x;
}
var_dump(foo(
true
@sunspikes
sunspikes / gameOfLife.php
Created May 31, 2017 16:07
Game Of Life
<?php
$initial = [
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 1, 1, 1, 0],
[0, 1, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
];
@sunspikes
sunspikes / IRRCalculator.php
Last active December 14, 2023 15:20
IRR Calculation in PHP
<?php
class IRRCalculator
{
const IRR_PRECISION = 11;
const IRR_INITIAL = 0.1;
const IRR_MAX_ITERATIONS = 20;
/**
* @param int[] $cashFlow
@sunspikes
sunspikes / .vimrc.local
Created July 21, 2016 15:37
SPF13 vimrc override
colorscheme molokai
set nospell
set nofoldenable " disable code folding
let g:DisableAutoPHPFolding = 1 " disable PIV's folding
let g:indent_guides_enable_on_vim_startup = 0
@sunspikes
sunspikes / serviceproviderinterface.zep
Created July 13, 2015 16:22
Pimple service provider interface in Zephir
namespace Simple;
/**
* Simple service provider interface.
*
* @author sunspikes
*/
interface ServiceProviderInterface
{
/**
@sunspikes
sunspikes / container.zep
Created July 13, 2015 16:20
Pimple container in zephir
namespace Simple;
/**
* Container main class.
*
* @author sunspikes
*/
class Container implements \ArrayAccess
{
private _values = [];