Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

egulhan

🎯
Focusing
Block or report user

Report or block egulhan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@egulhan
egulhan / Delete Slack Message Tool
Created Aug 2, 2019 — forked from uurtech/Delete Slack Message Tool
Delete All Slack Messages as a Service
View Delete Slack Message Tool
This is just a description of how to use Slack Message Tool,
You can backup and delete all the Slack messages at once with this easy app. Just choose what to do and our amazing magic will do that job for you.
https://www.messagebender.com/
@egulhan
egulhan / supervisor-queue-laravel-worker.conf
Created Apr 14, 2019
Supervisor configuration for Redis queue Laravel worker
View supervisor-queue-laravel-worker.conf
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=/usr/bin/php ../artisan queue:work redis --sleep=3 --tries=3
directory=/var/www/projects/project1/web/public/
autostart=true
autorestart=true
user=www-data
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/projects/project1/web/worker.log
@egulhan
egulhan / force-https-apache-directives.conf
Created Apr 7, 2019
use these force HTTPS apache directives (in .htaccess) if you have proxied server (such CloudFlare) or you are using a shared hosting
View force-https-apache-directives.conf
RewriteEngine On
# If we receive a forwarded http request from a proxy...
RewriteCond %{HTTP:X-Forwarded-Proto} =http [OR]
# ...or just a plain old http request directly from the client
RewriteCond %{HTTP:X-Forwarded-Proto} =""
RewriteCond %{HTTPS} !=on
# Redirect to https version
@egulhan
egulhan / calling-traits-contruct-method.php
Last active Apr 4, 2019
How to call trait's construct method in PHP
View calling-traits-contruct-method.php
<?php
namespace App\Models\Campaign;
use Illuminate\Database\Eloquent\Model;
use App\Classes\Traits\SetModelConnectionToSlave;
class CampaignDiscount extends Model
{
use SetModelConnectionToSlave {
@egulhan
egulhan / select2-placeholder-width-fix.css
Created Mar 18, 2019
FIX - select2 placeholder width cuts off text
View select2-placeholder-width-fix.css
/* FIX: Placeholder width cuts off text */
.select2-container--default .select2-search--inline .select2-search__field {
width: initial !important;
}
@egulhan
egulhan / request-with-multipart-data-using-guzzle.php
Created Jan 31, 2019
Request with Multipart data using Guzzle Http Client
View request-with-multipart-data-using-guzzle.php
<?php
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
function uploadImage($requestUrl, $imageFilePath)
{
$data = [];
try {
@egulhan
egulhan / generate-random-string.js
Created Jan 7, 2019
Generate a random string using Javascript
View generate-random-string.js
/**
* Generates random string
* @param length
* @returns {string}
*/
function generateRandomString(length) {
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
length = typeof length == 'undefined' ? 16 : length;
var rndCharIndex, rndStr = "";
@egulhan
egulhan / test-validations-of-formrequest.php
Last active Dec 3, 2018
Test validations of a FormRequest in Laravel
View test-validations-of-formrequest.php
<?php
namespace Tests\Unit;
use Tests\TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use App\Models\Notification\PushNotification;
use App\Modules\Partner\Requests\CreatePushNotificationRequest;
@egulhan
egulhan / request-with-cookies-using-guzzle.php
Created Nov 30, 2018
Request with cookies using Guzzle Http Client
View request-with-cookies-using-guzzle.php
<?php
$cookies = [
'geo' => 'TR',
'goip' => 'JO',
];
$cookieJar = \GuzzleHttp\Cookie\CookieJar::fromArray($cookies, 'example.com');
$client = new \GuzzleHttp\Client(['cookies' => $cookieJar]);
$response = $client->request('GET', $url);
@egulhan
egulhan / check-if-contain-domain-name.php
Last active Dec 3, 2018
Validate domain name or check if a string contains a domain name using PHP
View check-if-contain-domain-name.php
<?php
/**
* Checks if string contains a domain name
* @param $string
* @return false|int
*/
function checkIfContainsDomainName($string)
{
$pattern = '/(http[s]?\:\/\/)?(?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63}/';
You can’t perform that action at this time.