Skip to content

Instantly share code, notes, and snippets.

View uurtech's full-sized avatar
✈️
Works

Ugur KAZDAL uurtech

✈️
Works
View GitHub Profile
@egulhan
egulhan / test-validations-of-formrequest.php
Last active June 30, 2021 08:39
Test validations of a FormRequest in Laravel
<?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 November 30, 2018 09:09
Request with cookies using Guzzle Http Client
<?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 January 22, 2023 01:33
Validate domain name or check if a string contains a domain name using 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}/';
@tanmay27vats
tanmay27vats / twins.php
Created April 29, 2018 12:34
Two strings, a and b, are said to be twins only if they can be made equivalent by performing some number of operations on one or both strings. There are two possible operations: SwapEven: Swap a character at an even-numbered index with a character at another even-numbered index. SwapOdd: Swap a character at an odd-numbered index with a character…
function Twins($a, $b) {
$flag = false;
$a_len = count($a);
$b_len = count($b);
if($a_len != $b_len) {
throw new Exception('array index count mismatched!');
}
$result = [];
for($i = 0; $i<$a_len; $i++) {
@egulhan
egulhan / find-weeks-between-two-dates.php
Created April 25, 2018 09:31
Find weeks between two dates
<?php
/**
* Finds weeks by two dates
* @param $startDate
* @param $endDate
* @return array
*/
public static function findWeeksBetweenTwoDates($startDate, $endDate)
{
@alexsasharegan
alexsasharegan / waitgroup.ts
Last active April 1, 2020 08:58
Nodejs implementation of the Golang waitgroup.
import { EventEmitter } from "events"
export class WaitGroup extends EventEmitter {
public state: number
constructor(initialState: number = 0) {
if (initialState < 0) {
throw new RangeError()
}
super()
@xameeramir
xameeramir / default nginx configuration file
Last active April 27, 2024 12:35
The default nginx configuration file inside /etc/nginx/sites-available/default
# Author: Zameer Ansari
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
@vikas5914
vikas5914 / log.js
Last active December 12, 2023 14:09
Custom Logger Library with winston
const { createLogger, format, transports } = require('winston')
const moment = require('moment')
// set default log level.
const logLevel = 'info'
var logger = createLogger({
level: logLevel,
levels: {
fatal: 0,
@arxdsilva
arxdsilva / working_directory.go
Last active February 12, 2024 13:30
How to get the current working directory in golang
package main
// More info on Getwd()
// https://golang.org/src/os/getwd.go
//
import(
"os"
"fmt"
"log"
)
@jgrodziski
jgrodziski / docker-aliases.sh
Last active April 30, 2024 17:46
Useful Docker Aliases
############################################################################
# #
# ------- Useful Docker Aliases -------- #
# #
# # Installation : #
# copy/paste these lines into your .bashrc or .zshrc file or just #
# type the following in your current shell to try it out: #
# wget -O - https://gist.githubusercontent.com/jgrodziski/9ed4a17709baad10dbcd4530b60dfcbb/raw/d84ef1741c59e7ab07fb055a70df1830584c6c18/docker-aliases.sh | bash
# #
# # Usage: #