Skip to content

Instantly share code, notes, and snippets.

If you want to remove all dashes but one from the string '-aaa----b-c-----d--e---f' resulting in '-aaa-b-c-d-e-f', you cannot use str_replace. Instead, use preg_replace:
<?php
$challenge = '-aaa----b-c-----d--e---f';
echo str_replace('--', '-', $challenge).'<br>';
echo preg_replace('/--+/', '-', $challenge).'<br>';
?>
This outputs the following:
-aaa--b-c---d-e--f
@hasantktl
hasantktl / yii2 autocompletion
Created February 28, 2016 20:56
Yii2 IDE autocompletion for custom components
IDE autocompletion for custom components
Using IDE for development is quite typical nowadays because of the comfort it provides. It detects typos and errors, suggests code improvements and, of course, provides code autocomplete. For Yii 2.0 it works quite good out of the box but not in case of custom application components i.e. Yii::$app->mycomponent->something.
Using custom Yii class
The best way to give IDE some hints is to use your own Yii file. Let's check application's index.php:
<?php
// comment out the following two lines when deployed to production
<?php
$prefix='lib/';
require_once($prefix . 'Facebook/HttpClients/FacebookHttpable.php');
require_once($prefix . 'Facebook/HttpClients/FacebookCurl.php');
require_once($prefix . 'Facebook/HttpClients/FacebookCurlHttpClient.php');
require_once($prefix . 'Facebook/Entities/AccessToken.php');
require_once($prefix . 'Facebook/Entities/SignedRequest.php');
<?php
// include required files form Facebook SDK
require_once( 'Facebook/HttpClients/FacebookHttpable.php' );
require_once( 'Facebook/HttpClients/FacebookCurl.php' );
require_once( 'Facebook/HttpClients/FacebookCurlHttpClient.php' );
require_once( 'Facebook/Entities/AccessToken.php' );
require_once( 'Facebook/Entities/SignedRequest.php' );
zip -r <oluşturulacak zip dosyası yolu> <sıkıştırılacak klasör yolu>
Ör: zip -r ./yedek/2015-02-17.zip ./production/site1
<?php
$c = new CDbCriteria();
Hoge::model()->findAll($c);
// SELECT * FROM `hoge` `t`
$c = new CDbCriteria();
$c->addSearchCondition('t.fuga', null); // null, false, ''などは無視されるようです
Hoge::model()->findAll($c);
This file has been truncated, but you can view the full file.
/*
Türkiye'nin il, ilçe , semt, mahalle, posta kodu veritabanı
GÜNCEL : 19.04.2013
Kaynak : PTT
Oluşturan : http://www.twitter.com/tserpico
*/
DROP TABLE IF EXISTS `pk`;
CREATE TABLE `pk` (
`mahalle_id` bigint(10) NOT NULL AUTO_INCREMENT,

Git Tips

Config: Basic / Default

git config --global user.name "Your Name"
git config --global user.email "Your Email"
git config --global color.ui true
git config --global apply.whitespace nowarn

Github: Repo oluşturmak