Skip to content

Instantly share code, notes, and snippets.

View krisanalfa's full-sized avatar

Krisan Timur krisanalfa

  • Denpasar, Bali
View GitHub Profile
@krisanalfa
krisanalfa / Wrapper.php
Created June 6, 2017 05:00
Tiny Guzzle Wrapper
<?php
namespace Alpha;
use GuzzleHttp\Client;
class Wrapper
{
protected static $client;
@krisanalfa
krisanalfa / wordnet.js
Created January 17, 2017 05:16
Wordnet
// npm install "i" "cheerio" "stopword" "console.table"
// Configuration
const limit = 20
const lowest = 3
const highest = 20
const query = 'webcrawl'
const url = 'https://google.com/search?q=' + query
// Dependency
const inflect = require('i')()
@krisanalfa
krisanalfa / DropTable.php
Created October 10, 2016 13:28
Laravel Tinker Drop All Table
<?php
$pdo = DB::getPdo();
$tables = $pdo->query("SHOW FULL TABLES;")->fetchAll();
$sql = 'SET FOREIGN_KEY_CHECKS=0;';
foreach ($tables as $tableInfo) {
if('BASE TABLE' !== $tableInfo[1]) continue;
@krisanalfa
krisanalfa / ResourceController.php
Last active March 1, 2016 18:26
In replied to Mulia Nasution as response to my work partner Syaifudin Latief.
<?php
namespace App\Http\Controllers\Cart;
use Illuminate\Support\Facades\View;
use App\Http\Requests\Cart\StoreRequest;
use Illuminate\Support\Facades\Redirect;
use App\Http\Requests\Cart\UpdateRequest;
use App\Cart\Persistances\Cart as Persistant;
use App\Cart\Repositories\Cart as Repository;
@krisanalfa
krisanalfa / pdo_oci.c.patch
Created November 30, 2015 03:48
PDO Patch
--- pdo_oci.c.orig 2015-11-30 10:45:22.000000000 +0700
+++ pdo_oci.c 2015-11-30 10:45:33.000000000 +0700
@@ -31,7 +31,7 @@
#include "php_pdo_oci_int.h"
/* {{{ pdo_oci_functions[] */
-function_entry pdo_oci_functions[] = {
+zend_function_entry pdo_oci_functions[] = {
{NULL, NULL, NULL}
};
@krisanalfa
krisanalfa / ultimate.md
Created October 16, 2015 08:25
Slim + Eloquent + Oracle

Your composer.json file:

{
    "require": {
        "slim/slim": "^2.6",
        "illuminate/database": "^5.1",
        "symfony/var-dumper": "^2.7",
        "yajra/laravel-oci8": "^2.4"
    }
@krisanalfa
krisanalfa / config.m4.patch
Last active March 7, 2016 18:15
Patch to install pdo_oci. Read full description here: https://gist.github.com/krisanalfa/09b765bb95012cd36fbd
--- config.m4 2005-09-25 06:23:24.000000000 +0700
+++ config.m4.new 2015-10-02 15:42:52.000000000 +0700
@@ -8,15 +8,15 @@
PDO_OCI_VERSION=`grep '"ocommon"' $PDO_OCI_DIR/orainst/unix.rgs | sed 's/[ ][ ]*/:/g' | cut -d: -f 6 | cut -c 2-4`
test -z "$PDO_OCI_VERSION" && PDO_OCI_VERSION=7.3
elif test -f $PDO_OCI_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME.10.1; then
- PDO_OCI_VERSION=10.1
+ PDO_OCI_VERSION=10.1
elif test -f $PDO_OCI_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME.9.0; then
PDO_OCI_VERSION=9.0
@krisanalfa
krisanalfa / sublime-settings.json
Last active October 24, 2016 07:26
My Sublime Settings for PHP Developer
{
"rulers": [80, 120],
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"show_encoding": true,
"show_line_endings": true,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"word_wrap": false
}
@krisanalfa
krisanalfa / Encrypt.php
Created July 24, 2015 07:20
Simple class to encrypt and decrypt something with AES 256 encryption. Support for padding too!
<?php
/**
* Simple class to encrypt and decrypt something with AES 256 encryption.
*
* @author Krisan Alfa Timur <krisan47@gmail.com>
*/
class Encrypt
{
/**
@krisanalfa
krisanalfa / rm-assets.php
Created June 15, 2015 13:55
Remove Assets Recursively
<?php
header('Content-type: text/plain');
set_time_limit(0);
if (!function_exists('recursive_rmdir')) {
/**
* Remove directory recursively.
*
* @param string $dirPath Directory you want to remove.