Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Hello, mister!

Krisan Alfa Timur krisanalfa

:octocat:
Hello, mister!
View GitHub Profile
@krisanalfa
krisanalfa / Wrapper.php
Created Jun 6, 2017
Tiny Guzzle Wrapper
View Wrapper.php
<?php
namespace Alpha;
use GuzzleHttp\Client;
class Wrapper
{
protected static $client;
View wordnet.js
// 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 Oct 10, 2016
Laravel Tinker Drop All Table
View DropTable.php
<?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 Mar 1, 2016
In replied to Mulia Nasution as response to my work partner Syaifudin Latief.
View ResourceController.php
<?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;
View pdo_oci.c.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 Oct 16, 2015
Slim + Eloquent + Oracle
View ultimate.md

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 Mar 7, 2016
Patch to install pdo_oci. Read full description here: https://gist.github.com/krisanalfa/09b765bb95012cd36fbd
View config.m4.patch
--- 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 Oct 24, 2016
My Sublime Settings for PHP Developer
View sublime-settings.json
{
"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 Jul 24, 2015
Simple class to encrypt and decrypt something with AES 256 encryption. Support for padding too!
View Encrypt.php
<?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 Jun 15, 2015
Remove Assets Recursively
View rm-assets.php
<?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.