這篇文章旨在作為快速參考與展示。要更多完整的資訊,請見 John Gruber 原本的規格與 Github 偏好的 Markdown(Github-flavored Markdown,簡寫為GFM)資訊頁。
如果你正在找 Markdown Here 的小抄(Cheatsheet),這裡也有一篇。你也可以看看更多 Markdown 的工具。
譯註:可以參考這份中文版文件,有更詳盡的 Markdown 語法說明;如果需要可以練習的線上編輯器,可以試試看HackMD。
| <?php | |
| public function foos() { | |
| $relation = $this->hasMany('App\Bar'); | |
| return $relation; // default behaviour | |
| // modify the query builder | |
| $relation->where('foo','bar'); | |
| return $relation; |
這篇文章旨在作為快速參考與展示。要更多完整的資訊,請見 John Gruber 原本的規格與 Github 偏好的 Markdown(Github-flavored Markdown,簡寫為GFM)資訊頁。
如果你正在找 Markdown Here 的小抄(Cheatsheet),這裡也有一篇。你也可以看看更多 Markdown 的工具。
譯註:可以參考這份中文版文件,有更詳盡的 Markdown 語法說明;如果需要可以練習的線上編輯器,可以試試看HackMD。
| // -------------------------------------------------- | |
| // Flexbox SASS mixins | |
| // The spec: http://www.w3.org/TR/css3-flexbox | |
| // -------------------------------------------------- | |
| // Flexbox display | |
| @mixin flexbox { | |
| display: -webkit-box; | |
| display: -moz-box; | |
| display: -ms-flexbox; |
This gist shows how to create a GIF screencast using only free OS X tools: QuickTime and ffmpeg.
Forked from https://gist.github.com/dergachev/4627207. Updated to use a palette to improve quality and skip gifsicle.
To capture the video (filesize: 19MB), using the free "QuickTime Player" application:
| /** | |
| * Mass (bulk) insert or update on duplicate for Laravel 4/5 | |
| * | |
| * insertOrUpdate([ | |
| * ['id'=>1,'value'=>10], | |
| * ['id'=>2,'value'=>60] | |
| * ]); | |
| * | |
| * | |
| * @param array $rows |
These rules are adopted from the AngularJS commit conventions.
| <?php | |
| class MyModel extends Eloquent { | |
| public function getSql() | |
| { | |
| $builder = $this->getBuilder(); | |
| $sql = $builder->toSql(); | |
| foreach($builder->getBindings() as $binding) | |
| { |
| <?php | |
| class BaseModel extends Eloquent { | |
| public static function shouldReceive() | |
| { | |
| $repo = get_called_class() . 'RepositoryInterface'; | |
| $mock = Mockery::mock($repo); | |
| App::instance($repo, $mock); |
| 首先你需要一个不怕dns污染的http代理,比如连接到私人VPS的ssh tunnel+privoxy之类… | |
| 以下例子里我都使用10.8.0.1:8118作为代理服务器。 | |
| ## 让普通命令行工具使用代理 | |
| 可以在~/.profile或~/.bashrc里加上: | |
| ``` | |
| enable_proxy() { | |
| export http_proxy="10.8.0.1:8118" |
| <?php | |
| function is_valid_luhn($number) { | |
| settype($number, 'string'); | |
| $sumTable = array( | |
| array(0,1,2,3,4,5,6,7,8,9), | |
| array(0,2,4,6,8,1,3,5,7,9)); | |
| $sum = 0; | |
| $flip = 0; | |
| for ($i = strlen($number) - 1; $i >= 0; $i--) { | |
| $sum += $sumTable[$flip++ & 0x1][$number[$i]]; |