Skip to content

Instantly share code, notes, and snippets.

View technoknol's full-sized avatar
🎯
Focusing

Technoknol technoknol

🎯
Focusing
View GitHub Profile
@technoknol
technoknol / Php Stream - Write to temp stream and force user to download file.php
Created December 27, 2017 19:15
Php Stream - Write to temp stream and forcefully download file.
<?php
// Set the limit to 50 MB.
$fiveMBs = 50 * 1024 * 1024;
$fp = fopen("php://temp/maxmemory:$fiveMBs", 'r+');
fputs($fp, $couponString);
// Read what we have written.
rewind($fp);
header('Content-Description: File Transfer');
@technoknol
technoknol / PhpStorm Shortcuts Cheetsheet.md
Last active December 13, 2017 07:03
PhpStorm Shortcuts Cheetsheet

PhpStorm Shortcuts Cheetsheet

Key Combination Description
Ctrl + J Open live templates
Ctrl + Alt + Shift + J Select text (With multiple cursor)
Alt + Insert Open menu to Generate Documentation, Getter, Setter, etc.
@technoknol
technoknol / Nginx configuration server block (Virtual host) for Laravel Setup.
Last active December 12, 2017 07:23
Nginx configuration server block (Virtual host) for Laravel Setup.
server {
listen 80 ;
listen [::]:80;
root /var/www/html/blog2/public/;
index index.php index.htm index.nginx-debian.html;
server_name blog2.com;
location / {
@technoknol
technoknol / Type hinting with Interfaces PHP 3.php
Created September 3, 2017 18:41
Type hinting with Interfaces PHP - Example 3
<?php
// output :
// 10
// 100.234
interface printable {
public function printme();
}
abstract class Number {
@technoknol
technoknol / Type hinting with Interfaces PHP 2 .php
Created September 3, 2017 18:39
Type hinting with Interfaces PHP - Example 2
<?php
// output :
// 53.454492$
// 55.977413122858$
interface CarInterface {
public function calcTankVolume();
}
@technoknol
technoknol / Typehinting with Abstract class PHP.php
Created September 3, 2017 18:38
Typehinting with Abstract class PHP
<?php
// Output :
// 53.454492$
// 55.977413122858$
abstract class Car {
protected $model;
protected $height;
@technoknol
technoknol / Laravel - Disable SSL verification for SMTP.php
Created August 18, 2017 11:41
Laravel - Disable SSL verification for SMTP
<?php
// File :: config/mail.php
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
@technoknol
technoknol / hacker-rank-birthday-cake-candles.php
Created August 10, 2017 09:28
[Solved] Hacker Rank - Birthday Cake Candles
<?php
$handle = fopen ("php://stdin", "r");
function birthdayCakeCandles($n, $ar) {
// Complete this function
$max = $ar[0];
$counts = [];
foreach($ar as $a) {
if(isset($counts[$a])) {
$counts[$a]++;
@technoknol
technoknol / composer and helper.json
Last active September 4, 2017 19:31
Helper in Laravel
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
},
"files":[
"app/helpers.php" /* This line was added to load helper file. Then fire 'composer dump-autoload' command in terminal */
]
@technoknol
technoknol / debugger.php
Last active June 22, 2017 07:28
Laravel 5.4+ Query logging/ debugging/ printing via Middleware
<?php
// File location :: \app\Http\Middleware\debugger.php
namespace App\Http\Middleware;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Closure;
class debugger {