Skip to content

Instantly share code, notes, and snippets.

View uurtech's full-sized avatar
✈️
Works

Ugur KAZDAL uurtech

✈️
Works
View GitHub Profile
@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 / 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 / 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)
{
@egulhan
egulhan / calling-traits-contruct-method.php
Last active April 4, 2019 11:23
How to call trait's construct method in PHP
<?php
namespace App\Models\Campaign;
use Illuminate\Database\Eloquent\Model;
use App\Classes\Traits\SetModelConnectionToSlave;
class CampaignDiscount extends Model
{
use SetModelConnectionToSlave {
@uurtech
uurtech / scrollevent.js
Created December 30, 2019 11:30
Scroll Check by time.
let tempTimeStamp = 0;
window.addEventListener('scroll', function (event) {
if(((event["timeStamp"] - tempTimeStamp) / 1000) < 5){ //how many seconds you rely on.
tempTimeStamp = event["timeStamp"];
}else{
console.log(( event["timeStamp"] - tempTimeStamp) / 1000)
tempTimeStamp = event["timeStamp"];
//use withinviewport in here.
}
@uurtech
uurtech / script.groovy
Created February 28, 2020 16:41
Delete Old Builds Jenkins Script
//you can go to Manage Jenkins > Script Console
import jenkins.model.Jenkins
import hudson.model.Job
MAX_BUILDS = 55
Jenkins.instance.getAllItems(Job.class).each { job ->
println job.name
def recent = job.builds.limit(MAX_BUILDS)
for (build in job.builds) {
@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()
@uurtech
uurtech / controller.go
Created March 22, 2020 14:31
Return Http Response and then Perform other tasks
package main
import (
"fmt"
"net/http"
"sync"
"time"
)
func ping(w http.ResponseWriter, r *http.Request) {
@uurtech
uurtech / that.sh
Created May 16, 2020 07:37
Replace html tag recursively on linux
find . -type f -not -path '*/\.*' -exec sed -i -e "s@<base href=\"\/\/www.mydomain.com.\"\/>@\/@" {} \;
@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;