Skip to content

Instantly share code, notes, and snippets.

View samdark's full-sized avatar
🛠️
Improving everything

Alexander Makarov samdark

🛠️
Improving everything
View GitHub Profile
<?php
/**
* DuplicateFilter prevents Yii from exposing URLs starting with /index.php/ when showScriptName is false. Such
* URLs are automatically redirected to proper ones.
*
* To use add the following to your controller:
*
* ```php
* public function filters() {
* return array(
@samdark
samdark / books.md
Last active May 5, 2016 09:13
Книги

Распродаю свою книжную полку

  • Регулярные выражения, Дж. Фридл, 3-е издание

  • Разгони свой сайт, Н. Мациевский

  • Самоучитель Java 2, Ильдар Хабибуллин

  • Применение UML 2.0 и шаблонов проектирования, К. Ларман

  • CNE 050-63 Network Technologies

  • ActionScript, Шэм Бангал

Keybase proof

I hereby claim:

  • I am samdark on github.
  • I am samdark (https://keybase.io/samdark) on keybase.
  • I have a public key whose fingerprint is 22C9 A490 0E05 7C30 6A9D C678 F1AE 38B2 A108 39BF

To claim this, I am signing this object:

@samdark
samdark / gist:54764dd69b3e38140938
Created June 29, 2014 21:42
Git: squash last 3 commits together
git reset --soft HEAD~3
git commit -m 'new commit message'
function unhash(hash) {
var parts = [];
var letters = 'acdegilmnoprstuw';
while (hash !== 7) {
var index = hash % 37;
hash = (hash - index) / 37;
parts.unshift(letters[index]);
}
return parts.join('');
}
@samdark
samdark / routing.php
Created March 31, 2015 15:20
Routing
// Laravel
Route::get('user/{id}', 'UserController@showProfile');
// Yii
'user/<id>' => 'user/profile',
@samdark
samdark / squash-merge.sh
Last active October 22, 2015 11:49
sqash-merge pull request
git checkout -b local-branch-name master
git pull https://github.com/username/repo.git remote-branch-name
git --no-pager show -s --format='%an <%ae>' FETCH_HEAD
git merge --squash local-branch-name
git commit -am 'commit message' --author="author name <[email protected]>"
git push origin master
@samdark
samdark / Sam Dark.icls
Created August 11, 2016 13:25
My PhpStorm color schema
<scheme name="Sam Dark" version="142" parent_scheme="Default">
<option name="LINE_SPACING" value="1.05" />
<option name="EDITOR_FONT_SIZE" value="15" />
<option name="EDITOR_LIGATURES" value="true" />
<option name="CONSOLE_FONT_NAME" value="Monospaced" />
<option name="CONSOLE_FONT_SIZE" value="13" />
<option name="EDITOR_FONT_NAME" value="Fira Code" />
<colors>
<option name="WHITESPACES" value="f2f2f2" />
</colors>
@samdark
samdark / phpunit_array_assertions.php
Created October 10, 2016 11:21
PHPUnit array assertions
public static function assertArrayStructure($keys, $array)
{
$arrayKeys = array_keys($array);
$missing = array_diff($keys, $arrayKeys);
$unexpected = array_diff($arrayKeys, $keys);
$message = 'Keys are wrong.';
if ($missing !== []) {
$message .= ' Missing: ' . implode(', ', $missing) . '.';
-- Cleans up IPB 3 database before importing it into another forum engine
-- tbl_* are project specific, could be removed
-- Remove banned members and members with no posts
delete m
from ipb_members m
left join tbl_user u on u.id = m.member_id
where
(
member_banned = 1