Skip to content

Instantly share code, notes, and snippets.

package main
import (
"database/sql"
"fmt"
_ "github.com/lib/pq"
"log"
"time"
)
package main
import (
"database/sql"
"fmt"
_ "github.com/lib/pq"
"log"
"time"
)
@gyaan
gyaan / matrix_path_exist_bw_00_nn.php
Last active February 7, 2019 09:02
check if path exist between 00 to nn element of 2d matrix
<?php
$arr = [[1, 1, 1, 0, 0],
[0, 1, 1, 1, 0],
[1, 0, 0, 1, 0],
[0, 0, 1, 0, 1],
[0, 0, 0, 0, 1]];
var_dump(getPath(0, 0, $arr));
@gyaan
gyaan / UserController.php
Created May 29, 2018 17:32
Avoid Race condition using lockForUpdate function and MySQL transactions.
<?php
namespace App\Http\Controllers;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
class UserController extends Controller
{
@gyaan
gyaan / UserController.php
Created May 29, 2018 17:32
Avoid Race condition using lockForUpdate function and MySQL transactions.
<?php
namespace App\Http\Controllers;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
class UserController extends Controller
{
@gyaan
gyaan / base64ToImage
Created July 27, 2014 19:00
convert base64 image string to actual image
<?php
function base64StringToImage($base64String, $writeFolder, $newFileName)
{
//open file
$file = fopen($writeFolder . "/" . $newFileName, "wb");
//problem with open a file
if (!$file)
throw new \Exception('can able to open file');
Options +FollowSymbolics
RewriteEngine on
#request routing
RewriteRule ^([a-zA-Z_-]*)$ index.php?name=$1 [nc,qsa]