Skip to content

Instantly share code, notes, and snippets.

View mustafatoker's full-sized avatar
🎯
Focusing

Mustafa TOKER mustafatoker

🎯
Focusing
View GitHub Profile
package com.security.test.config;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
location /files {
rewrite ^/files/?(.*)$ /files/load_file.php?file=$1 last;
}
@mustafatoker
mustafatoker / BladeServiceProvider.php
Last active April 4, 2018 07:33
Laravel Blade to deal with null dates. Example; @Date($object->updated_at)
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class BladeServiceProvider extends ServiceProvider
{
/**
<?php
if ( ! isset($array['q']) || ! isset($array['w']) || ! isset($array['e'])) {
// PANIC
}
# Becomes
if ( ! isset($array['q'], $array['w'], $array['e'])) {
// OH NO!
@mustafatoker
mustafatoker / query-dsl.json
Last active January 21, 2018 18:17
ElasticSearch Query DSL of Fetch data from each category
{
"size" : 0,
"aggs": {
"group" : {
"terms" : {
"field" : "category_id"
},
"aggs" : {
"group_docs" : {
"top_hits" : {
@mustafatoker
mustafatoker / .bash_aliases
Created August 27, 2017 16:53
Laravel Bash Aliases
alias art="php artisan"
alias c='composer'
alias cclear='php artisan cache:clear'
alias cdo="composer dump-autoload -o"
alias cu='composer update'
alias ci='composer install'
alias chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
alias d='docker'
alias d='php artisan db:seed'
alias doc='docker-compose'
@mustafatoker
mustafatoker / Automatically Running PHPUnit With Facebook's Watchman
Created July 23, 2017 09:14
A little bash script to run tests when a file has been changed
#!/usr/bin/env bash
function pw {
# Register the command you want to run when changes are detected here
run="clear && printf '\e[3J' && vendor/bin/phpunit"
# Retrieve the custom argments. If none are provided, default to "tests"
[[ -n $@ ]] && args=$@ || args="tests"
# Run the command first...
@mustafatoker
mustafatoker / increment.php
Last active February 13, 2017 10:04
Increment integer in string
<?php
function increment($matches) {
return ++$matches[1];
}
$string = 'value1';
$string = preg_replace_callback( "|(\d+)|", 'increment', $string);
echo $string; // value2
<?php
namespace App\Services;
use App\Post;
class Slug
{
/**
* @param $title