Skip to content

Instantly share code, notes, and snippets.

@pebriana
pebriana / gist:fb2e2ca67ab8d4c24b4001550415d37c
Created April 12, 2016 09:31
redirect to https and remove index.php
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
@pebriana
pebriana / wp-query-ref.php
Created April 12, 2016 03:53 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
@pebriana
pebriana / uri.js
Created April 6, 2016 07:34 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@pebriana
pebriana / yii.php
Created April 6, 2016 07:26 — forked from fadib/yii.php
Yii 1 -> Yii 2
<?php
CHtml::cssFile() => Html::cssFile()
CHtml::scriptFile() => Html::jsFile()
CHtml::link() => Html::a()
CHtml::image() => Html::img()
CHtml::submitButton() => Html::submitButton()
// View
$this->renderPartial() => $this->render()
@pebriana
pebriana / how to git
Last active July 18, 2019 08:52
how to git
Set up your local directory
mkdir /path/to/your/project
cd /path/to/your/project
git init
git remote add origin [email protected]:combro/misro-project.git
Create your first file, commit, and push
echo "Benyamin Sueb" >> contributors.txt
@pebriana
pebriana / gist:b3a08c1d9137c5fbbb0a
Created March 4, 2016 02:51
error: src refspec master does not match any. error: failed to push some refs to 'ssh://xxxxx.com/project.git'
http://stackoverflow.com/questions/4181861/src-refspec-master-does-not-match-any-when-pushing-commits-in-git?answertab=votes#tab-top
Maybe you just need to commit. I ran into this when I did:
mkdir repo && cd repo
git remote add origin /path/to/origin.git
git add .
Oops! Never committed!
@pebriana
pebriana / gii commandline
Last active March 3, 2016 07:56
gii model generate from commandline
# change path to your application's base path
cd path/to/AppBasePath
# show help information about Gii
yii help gii
# show help information about the model generator in Gii
yii help gii/model
# generate City model from city table
@pebriana
pebriana / Clean Code
Last active February 22, 2016 07:43
Clean Code
https://github.com/deerawan/clean-code/blob/master/README.md
# Clean Code
## Conditionals
### Boolean Assignments
```javascript
@pebriana
pebriana / main.php
Created February 10, 2016 09:05 — forked from cebe/main.php
REST routing with Yii 2 UrlManager
<?php
return array(
/* ... */
'components' => array(
/* ... */
'urlManager' => array(
'enablePrettyUrl' => true,
'rules' => require(__DIR__ . '/routes.php'),
),
@pebriana
pebriana / gist:9cb1512661a617a7ca0f
Created January 27, 2016 14:54
yii2 after save
public function afterSave($insert, $changedAttributes)
{
if (($this->scenario == 'user' || $this->scenario == 'guest') && $this->isNewRecord)
\Yii::$app->mailer->compose('new_comment', ['model' => $this])
->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot'])
->setTo(Email::getByGroup(Email::COMMENTS))
->setSubject('Some subject')
->send();
parent::afterSave($insert, $changedAttributes);
}