Aug
2,
2019
Unagi, kanto-style
Almost all unagi in Tokyo is cooked kanto-style, meaning the eel is steamed before grilling - so was this one.
I prefer kansai-style (=no steaming) but this kanto-style eel was pretty good.
Jul
2,
2019
PHP regex: ^ and $ vs \A and \z
$name = "joe";
if (preg_match('/^[a-zA-Z]+$/', $name) {
}
Chances are, you probably want use this instead:
if (preg_match('/\A[a-zA-Z]+\z/', $name) {
}
Why?
Use of ^ is OK, but $ matches line break characters.
So,
$name = "joe¥n";
if (preg_match('/^[a-zA-Z]+$/', $name) {
echo "match!";
}
Will display "match!" - which is probably something you don't want.
Jun
26,
2019
The City Bakery
Their burgers and wraps are good too.
I had the Jerk Chicken Wrap today. It was fantastic.
Jun
24,
2019
Tonkotsu-ramen
Jun
23,
2019
Yuki
on my wife's pillow.
Jun
13,
2019
Japanese melon: Ibara King
The name Ibara King is a pun on the prefecture name Ibaraki. Sorry name but the fruit is delicious, it is sweet and has a nice solid texture. The Higo Green I had the other day was softer, more fragrant.
I give this one three stars too.
Jun
12,
2019
Japanese melon: Higo Green
I like green ones best - here is a picture of Higo Green, a melon farmed in Kumamoto. It was yummy, I give it three stars.
Jun
12,
2019
CakePHP3: Two sets of pagination for the same model
Here is how to do it, assuming we have a table called articles, and we want pagination for current articles and for past (expired) articles. In your controller, write this:
$this->paginate = [
'Articles' => [
'scope' => 'current_articles',
],
'PastArticles' => [
'scope' => 'past_articles',
],
];
TableRegistry::config('PastArticles', [
'className' => 'App\Model\Table\ArticlesTable',
'table' => 'articles',
'entityClass' => 'App\Model\Entity\Article',
]);
$currentArticles = $this->paginate(
$this->Articles->find('all', [
'scope' => 'current_articles'
])->where(['expiry >' => Time::now()])
);
$pastArticles = $this->paginate(
TableRegistry::getTableLocator()->get('PastArticles')->find('all', [
'scope' => 'past_articles'
])->where(['expiry <=' => Time::now()])
);
$this->set(compact('currentArticles','pastArticles'));
And in your view, do this:
$this->Paginator->options(['model' => 'Articles']);
echo $this->Paginator->first('<<');
echo $this->Paginator->prev('<');
echo $this->Paginator->numbers();
echo $this->Paginator->next('>');
echo $this->Paginator->last('>>');
$this->Paginator->options(['model' => 'PastArticles']);
echo $this->Paginator->first('<<');
echo $this->Paginator->prev('<');
echo $this->Paginator->numbers();
echo $this->Paginator->next('>');
echo $this->Paginator->last('>>');
Jun
8,
2019
CakePHP3: Check if user browsing from iPad
<?php
use Mobile_Detect;
$mb = new Mobile_Detect;
if($mb->isIpad()){
echo "is ipad";
}else{
echo "is not ipad";
}
There are other handy methods such is isMobile(), isChrome() etc:
http://mobiledetect.net/
×
- If you are a bloguru member, please login.
Login - If you are not a bloguru member, you may request a free account here:
Request Account