Skip to content

Instantly share code, notes, and snippets.

View binaryoung's full-sized avatar
🌊

young binaryoung

🌊
View GitHub Profile
@binaryoung
binaryoung / letsencrypt_notes.sh
Created February 28, 2018 12:16 — forked from lachesis/letsencrypt_notes.sh
Set up LetsEncrypt using acme.sh without root
# How to use "acme.sh" to set up Lets Encrypt without root permissions
# See https://github.com/Neilpang/acme.sh for more
# This assumes that your website has a webroot at "/var/www/<domain>"
# I'll use the domain "EXAMPLE.com" as an example
# When this is done, there will be an "acme" user that handles issuing,
# updating, and installing certificates. This account will have the following
# (fairly minimal) permissions:
# - Host files at http://EXAMPLE.com/.well-known/acme-challenge
<?php
$data = [
['THE', 'A'],
['ELEPHANT', 'APPLE', 'CAR'],
['WALKED', 'DROVE', 'SAT'],
];
function solve(array $data){
$current = array_shift($data);
@binaryoung
binaryoung / add-embed-tweet-meta-box.php
Created March 13, 2018 04:53 — forked from paulund/add-embed-tweet-meta-box.php
Add custom post meta data input boxes to the WordPress post pages.
<?php
function add_embed_tweet_meta_box() {
add_meta_box(
'paulund_embed_tweet_meta_box', // $id
'Post Embed Tweets Meta Box', // $title
'show_embed_tweet_meta_box', // $callback
'post', // $page
'normal', // $context
'high'); // $priority
}
@binaryoung
binaryoung / replaceSource.sh
Created March 27, 2018 03:29
LInux 替换为中科大源
sudo sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
@binaryoung
binaryoung / invokeMethod.php
Created April 12, 2018 10:04
Invoke None Public Method
<?php
/**
* Call protected or private method of a class.
*
* @param object $object instantiated object that we will run method on.
* @param string $method_name method name to call
* @param array $parameters array of parameters to pass into method.
*
* @return mixed Method return.
*/
@binaryoung
binaryoung / Request.php
Created July 2, 2018 02:55
Laravel Form Request Base Class
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class Request extends FormRequest
{
public function authorize()
{
return true;
@binaryoung
binaryoung / demo.php
Created August 20, 2018 08:53
big data array pagination
<?php
define('START', microtime(true));
define('START_MEMORY', memory_get_peak_usage(true));
collect(range(0, 1000000))->slice(500000)->forPage(3,20);
define('END', microtime(true));
define('END_MEMORY', memory_get_peak_usage(true));
echo END - START,',',END_MEMORY - START_MEMORY;
server {
listen ${3:-80};
listen ${4:-443} ssl http2;
server_name .$1;
root $2;
index index.html index.htm index.php;
charset utf-8;