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
@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 / 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@example.com>"
git push origin master
@samdark
samdark / routing.php
Created March 31, 2015 15:20
Routing
// Laravel
Route::get('user/{id}', 'UserController@showProfile');
// Yii
'user/<id>' => 'user/profile',
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 / 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'

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 / books.md
Last active May 5, 2016 09:13
Книги

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

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

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

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

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

  • CNE 050-63 Network Technologies

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

<?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(
<?php
$db = new PDO('mysql:host=localhost;dbname=rmc2', 'root');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
function benchmark($callback){
$start = microtime(true);
for ($i = 0; $i < 100; $i++)
$callback();
return microtime(true) - $start;
}
<?php
class Wrapper {
private $value;
private $isHit;
function __construct($isHit, $value)
{
$this->isHit = $isHit;
$this->value = $value;
}