Skip to content

Instantly share code, notes, and snippets.

@mouson
mouson / SampleTraitTest.php
Created August 23, 2019 06:23
SampleTraitTest.php
<?php
use Mockery as m;
use PHPUnit\Framework\TestCase;
class SampleTest extends TestCase
{
protected function setUp()
{
parent::setUp();
SELECT id, name, createtime
  FROM pre_tamplate AS tamplate
  JOIN pre_table AS table
 WHERE tamplate.id = table.id
   AND table.id = 1234;
@mouson
mouson / Apple_special_deal_crawler_demo.php
Created September 14, 2017 09:39
蘋果官網整修品頁面新品取得機器人
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use Goutte\Client as Goutte_Client;
$client = new Goutte_Client();
$records_path = __DIR__ . '/../logs/records.log';
$apple_url = 'https://www.apple.com';
$country_code = '/tw';
$specialdeals_url = '/shop/browse/home/specialdeals/mac';
@mouson
mouson / gist:47742cb6def1166fa76b815246f46a83
Created June 16, 2017 10:00
Use Mockery mock class and alias static method
<?php
use Mockery as m;
use PHPUnit\Framework\TestCase;
class StaticClassTest extends TestCase
{
protected function tearDown()
{
m::close();
<?php
namespace MyDB;
use Illuminate\Support\ServiceProvider;
use MyDB\Connectors\MyDBConnector as Connector;
class MyDBServiceProvider extends ServiceProvider
{
/**
# Before Script
before_script:
- composer self-update
- composer install --prefer-dist > /dev/null
- cp .env.example .env
- php artisan key:generate
- php artisan migrate:refresh
# Services
services:
# Before Tests
before_script:
- bash ci/docker_setup.sh > /dev/null
- composer self-update
- composer install --prefer-dist > /dev/null
- cp .env.gitlab .env
- php artisan key:generate
# Services
services:
@mouson
mouson / install-tmux
Last active October 13, 2015 08:04 — forked from rothgar/install-tmux
Install tmux 1.9 on rhel/centos 6
# Install tmux on Centos release 6.5 up
# install deps
yum install gcc kernel-devel make ncurses-devel
# DOWNLOAD SOURCES FOR LIBEVENT AND MAKE AND INSTALL
curl -OL https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar -xvzf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure --prefix=/usr/local
<?php
/* *************************************************
@Name: Lifetype to Wordpress
@description:
這是一個可以直接在主機上執行的轉換程式,
可以協助您將Lifetype中「指定的」部落格,
所有文章、類別、迴響、引用、我的連結,
轉換到Wordpress系統「指定的」部落格中。
@Version: V1.10
V1.10 加入可修改base網址
<?php
if (function_exists("date_default_timezone_set")) {
date_default_timezone_set("UTC");
}
function simple() {
$a = 0;
for ($i = 0; $i < 1000000; $i++)
$a++;