Skip to content

Instantly share code, notes, and snippets.

View borantula's full-sized avatar

Bora Yalcin borantula

View GitHub Profile
@borantula
borantula / cakephp-features.php
Created January 14, 2017 21:24
CakePHP Features Example
<?php
/**
* Components are tightly connected (or appears so) to the controllers
* and as the application grows bigger, some of the work is done other places
* like event listener classes, mailers, shell commands, custom project classes etc.
* When that happens this can lead to code duplication from your components to those places.
*
* On a CakePHP project we are working on we starting using a structure called Features (idea taken
* from a Laravel community), where we have a "Feature Runner" trait, and a feature class structure which
* only includes a constructor and handle public methods and run as in example. By adding use FeatureRunner to any class
@borantula
borantula / gist:1b00003cf3b37a42c549b347950e6c81
Created November 2, 2016 08:31
find all php shorttags reges
<\?(?!(php|=|xml))(\s|\t|\n)
@borantula
borantula / processwire-3-namespace-migrator.php
Last active April 25, 2016 07:38
Processwire 3 Namespace Migrator
<?php
/**
* This script attempts to add namespace Processwire to every .php and .module file in the given directory.
* It worked fine for my project but I cannot guarantee for you, so PLEASE take a backup or two before you
* attempt to try it.
*
* To use it put this in your root folder and navigate with your browser to the file like
* example.com/processwire-3-namespace-migrator.php
* Also you should disable the compiler by setting $config->templateCompile=false; in your /site/config.php.
*
@borantula
borantula / eksisozlukfix
Created February 28, 2016 09:45
Quick css fix for new unreadable design on eksisozluk
body {
background-color: #ddd;
}
#entry-list>li {
position: relative;
padding: 30px 20px;
background:#f3f3f3;
margin:10px 0;
font-size:18px;
border:1px solid #ccc;
@borantula
borantula / .gitignore
Created October 13, 2015 09:54
WordPress gitignore
.htaccess
wp-config.php
wp-content/uploads/
wp-cli.yml
wp-content/blogs.dir/
wp-content/upgrade/
wp-content/backup-db/
wp-content/backupwordpress*
wp-content/advanced-cache.php
wp-content/wp-cache-config.php
@borantula
borantula / gist:5589153b2a235d8ea79f
Last active September 21, 2015 12:48
Bootstrap Pagination for WordPress
function wp_bootstrap_pagination( $wp_query = false ) {
if($wp_query == false) {
global $wp_query;
}
$big = 999999999;
$pages = paginate_links(array(
'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
'format' => '?page=%#%',
'current' => max(1, get_query_var('paged')),
@borantula
borantula / single.php
Created August 10, 2015 13:33
WordPress links for previous and next post
<div class="entry__arrows visible-md visible-lg">
<a class="entry__arrow entry__arrow--prev" href="<?=get_permalink(get_adjacent_post(false,'',false));?>"></a>
<a class="entry__arrow entry__arrow--next" href="<?=get_permalink(get_adjacent_post(false,'',true));?>"></a>
</div>
@borantula
borantula / bootstrap-modal-control.js
Created August 3, 2015 09:46
Bootstrap Modal Control Class for easy usage
BootstrapModalControl = {
init : function(){
//for necessary binding
},
modelBox : function(){
//this could be dynamic if you have more than one modal
return $('#admin-modal');
},
@borantula
borantula / turkish-lowercase-uppercase.js
Created October 5, 2014 14:02
Turkish case conversion in JavaScript
//source: http://stackoverflow.com/questions/1850232/turkish-case-conversion-in-javascript
String.prototype.turkishToUpper = function(){
var string = this;
var letters = { "i": "İ", "ş": "Ş", "ğ": "Ğ", "ü": "Ü", "ö": "Ö", "ç": "Ç", "ı": "I" };
string = string.replace(/(([iışğüçö]))+/g, function(letter){ return letters[letter]; })
return string.toUpperCase();
}
String.prototype.turkishToLower = function(){
@borantula
borantula / gitclearcache.sh
Created August 7, 2014 07:18
Git clear cache
git rm -r --cached .
git add --all
git commit -am 'git cache cleared'