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

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 / routing.php
Created March 31, 2015 15:20
Routing
// Laravel
Route::get('user/{id}', 'UserController@showProfile');
// Yii
'user/<id>' => 'user/profile',
@samdark
samdark / gist:1001489
Created May 31, 2011 23:36
Yii: switching theme based on view name
<?php
/**
* Q:
*
* Hi, could please add this feature please. Here is my case, I have two themes
* and I have modules. How can one set each view file in the modules to use
* either one of the themes. Such if the view is admin use backoffice theme and
* if view is index use siteNew theme. I so someting like setBasePath and
* setBaseUrl but I don not know where they should be exactly.
*
@samdark
samdark / git_change_committer_info
Created September 26, 2011 11:57
Git: change committer info for all commits in a branch
git filter-branch --commit-filter '
if [ "$GIT_COMMITTER_NAME" = "Alex" ];
then
GIT_COMMITTER_NAME="Alexander Makarov";
GIT_AUTHOR_NAME="Alexander Makarov";
GIT_COMMITTER_EMAIL="sam@rmcreative.ru";
GIT_AUTHOR_EMAIL="sam@rmcreative.ru";
git commit-tree "$@";
else
git commit-tree "$@";
@samdark
samdark / yii_postcommit_hook_checklist.md
Created October 27, 2011 21:23
Yii postcommit hook checklist
  1. Run "yii migrate --interactive=0" from "protected" dir.
  2. Check that "protected/runtime" and "www/assets" are writable by webserver process.
  3. Clear assets dir.
  4. Run unit tests and send an email to project members only if failed.
@samdark
samdark / interview_street_test_runner.php
Created November 26, 2011 18:36
interview street test runner
<?php
/**
* interview street test runner
*
* Test code should be in /test.php.
* Tests should be unpacked under /tests.
*/
$dir=dirname(__FILE__) . "/tests";
$di=new DirectoryIterator($dir);
@samdark
samdark / git_revert_all
Created December 30, 2011 20:40
Fully revert Git working copy changes and clean non-repository files
git checkout .
git-clean -f
@samdark
samdark / assembla-time-summary.php
Created February 22, 2012 18:39
Assembla multi-project time summary
<?php
// first you need to export all your time you want to sum up and copy to this script dir
$sum = 0;
$f = fopen('export_tasks.csv', 'r');
if($f)
{
while (($data = fgetcsv($f, 1000, ",")) !== FALSE) {
if(!isset($data[4]))
continue;
@samdark
samdark / Component.php
Created May 30, 2012 12:21
Yii2, Component
<?php
/**
* Component class file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\base;
@samdark
samdark / render_leveled_list_as_ul.php
Created June 29, 2012 08:31
Render leveled list as unordered list
<?php
function render_level_list($items)
{
$level=0;
foreach($items as $item)
{
if($item->level==$level) {
echo "</li>\n";
}