Skip to content

Instantly share code, notes, and snippets.

View mtigdemir's full-sized avatar
🏠
Working from home

Muharrem Tigdemir mtigdemir

🏠
Working from home
View GitHub Profile
@mtigdemir
mtigdemir / camel_case_space_ucfirst.php
Last active August 29, 2015 14:25
Camel Case Space And Uc First
<?php
ucfirst(preg_replace('/([a-z])([A-Z])/s','$1 $2', $key))
(function(global) {
var google = global.google;
var directionsService = new google.maps.DirectionsService();
var directionsDisplay;
// initialize google map
var initialize = function() {
var mapOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 5,
@mtigdemir
mtigdemir / laravel-array-validation.php
Created August 12, 2015 09:13
Laravel Array Validation
<?php
$validator = Validator::make($request->all(), $rules);
$validator->each('restrictIp' , ['required' , 'ip']);
@mtigdemir
mtigdemir / UUID.php
Last active August 29, 2015 14:27 — forked from dahnielson/UUID.php
Pure PHP UUID generator
<?php
/**
* UUID class
*
* The following class generates VALID RFC 4122 COMPLIANT
* Universally Unique IDentifiers (UUID) version 3, 4 and 5.
*
* UUIDs generated validates using OSSP UUID Tool, and output
* for named-based UUIDs are exactly the same. This is a pure
* PHP implementation.
@mtigdemir
mtigdemir / HttpsMiddleware.php
Created August 28, 2015 08:02
Laravel Https Force Middleware
<?php
namespace App\Http\Middleware;
use Closure;
use URL;
//Add This middleware to Http/Kernel.php $middleware array
class HttpsMiddleware
@mtigdemir
mtigdemir / alter_enum_colum.sql
Created August 31, 2015 07:33
Mysql Alter Table Enum Table
alter table my_table modify column status enum ('A', 'B', 'C');
DESCRIBE my_table;
@mtigdemir
mtigdemir / readme.md
Created October 8, 2015 14:02 — forked from juice49/readme.md
Using the Laravel Validator, make a field required if another field is set to a given attribute.

Setup

  • Add this file to application/libraries (or, if you are already extending the Validator class, add the contents there).
  • Remove Validator alias from config/application.php in order to avoid conflicts.
  • Add "required_if_attribute" => "The :attribute field is required." to application/language/[language]/validation.php.

Usage

Define the rule using:

required_if_attribute:[field],[operator],[value]

@mtigdemir
mtigdemir / git-template-glbal.sh
Created November 25, 2015 20:28
Global Git Commit Hook
git config --global init.templatedir '~/.git-templates'
mkdir -p ~/.git-templates/hooks
touch ~/.git-templates/hooks/pre-commit
chmod a+x ~/.git-templates/hooks/pre-commit
@mtigdemir
mtigdemir / helpers.php
Created December 4, 2015 15:34 — forked from mabasic/helpers.php
config_path function for Lumen framework
<?php
if ( ! function_exists('config_path'))
{
/**
* Get the configuration path.
*
* @param string $path
* @return string
*/
@mtigdemir
mtigdemir / phpcs.xml
Last active February 2, 2016 15:10
Php Code Sniffer
<?xml version="1.0"?>
<ruleset name="PSR2">
<description>The PSR-2 coding standard.</description>
<!-- PHP code MUST use the long <?php ?> tags or the short-echo <?= ?> tags; it MUST NOT use the other tag variations. -->
<rule ref="Generic.PHP.DisallowShortOpenTag.EchoFound">
<severity>0</severity>
</rule>
<!-- PHP code MUST use only UTF-8 without BOM. -->