Skip to content

Instantly share code, notes, and snippets.

@jaceju
jaceju / .eslintrc
Created August 5, 2016 04:35 — forked from cletusw/.eslintrc
ESLint Reset - A starter .eslintrc file that resets all rules to off and includes a description of what each rule does. From here, enable the rules that you care about by changing the 0 to a 1 or 2. 1 means warning (will not affect exit code) and 2 means error (will affect exit code).
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"defaultParams": false, // enable default function parameters
"forOf": false, // enable for-of loops
"generators": false, // enable generators
"objectLiteralComputedProperties": false, // enable computed object literal property names
@jaceju
jaceju / mocha-coding-style-guide.md
Last active October 19, 2016 06:18
Mocha 測試寫法指引

Mocha 測試寫法 Patterns

require 一律放在最前面

儘可能不要在 describeit 中使用 require

把待測試的類別引用放在工具引用的後面

例如:

@jaceju
jaceju / tmux.conf
Created September 22, 2016 06:54 — forked from shinzui/tmux.conf
tmux.conf
# ~/.tmux.conf
#
# See the following files:
#
# /opt/local/share/doc/tmux/t-williams.conf
# /opt/local/share/doc/tmux/screen-keys.conf
# /opt/local/share/doc/tmux/vim-keys.conf
#
# URLs to read:
#
@jaceju
jaceju / laravel-collection.md
Last active November 25, 2016 05:19
考題: Laravel Collection 應用

考題: Laravel Collection 應用

參考以下 $usersData ,請利用 Laravel Collection 實作以下規格:

  1. 先以 isVip 分組, true 排前面, false 排後面。
  2. 對已經分組的結果,再以 isOnline 分組, true 排前面, false 排後面。
  3. 對所有分組以 followerCount 由高至低排序。
  4. 把所有分組結果重新組合成只有一層的 array 。
  5. 預期重新排序過的 $usersData 應如下:
@jaceju
jaceju / after-refactoring.php
Last active December 6, 2016 06:41
ISP 原則實例
<?php
class Mailer
{
// Mailer 只依賴在 Mailable 介面, Mailable 只有一個 getMail 方法。
public function send(Mailable $target)
{
$mail = $target->getMail();
// ...
<?php
namespace Feature\Helper;
use SebastianBergmann\CodeCoverage\Filter;
use SebastianBergmann\CodeCoverage\CodeCoverage as PHPUnitCodeCoverage;
use SebastianBergmann\CodeCoverage\InvalidArgumentException;
use SebastianBergmann\CodeCoverage\Report\Clover;
use SebastianBergmann\CodeCoverage\Report\Html\Facade as Html;
use SebastianBergmann\CodeCoverage\Report\Text;
@jaceju
jaceju / rename.php
Created March 9, 2018 02:57
Rename files
<?php
use Illuminate\Support\Str;
require __DIR__ . '/vendor/autoload.php';
$fs = new \Illuminate\Filesystem\Filesystem();
$filePaths = $fs->glob(__DIR__ . '/src/Schema/*/Create*.php');
foreach ($filePaths as $filePath) {
$file = new SplFileInfo($filePath);
@jaceju
jaceju / migration.php
Created March 9, 2018 03:01
Use Laravel Migration standalone
<?php
use Illuminate\Container\Container;
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Database\ConnectionResolverInterface;
use Illuminate\Database\Migrations\DatabaseMigrationRepository;
use Illuminate\Database\Migrations\MigrationRepositoryInterface;
use Illuminate\Database\Migrations\Migrator;
use Illuminate\Events\Dispatcher;
@jaceju
jaceju / shell_array.sh
Created May 8, 2018 03:42
Shell Script 的陣列範例
#!/bin/bash
versions=("5.6.24" "7.0.9")
function say()
{
value=$1
echo -e "php-$value\n"
}
@jaceju
jaceju / NavBar.vue
Created July 5, 2018 03:22
Element UI NavBar with Vue-Router
<template>
<el-menu :default-active="$route.path"
class="el-menu-demo"
mode="horizontal"
@select="handleSelect"
:router="true">
<el-menu-item index="/" route="/">Deploy Status</el-menu-item>
<el-menu-item index="/projects" route="/projects">Projects</el-menu-item>
<el-menu-item index="/services" route="/services">Services</el-menu-item>
</el-menu>