This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Container | |
{ | |
protected $setings = array(); | |
public function set($abstract, $concrete = null) | |
{ | |
if ($concrete === null) { | |
$concrete = $abstract; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
require 'simple_html_dom.php'; // http://sourceforge.net/projects/simplehtmldom/ | |
if (empty($argv[1])) { | |
echo 'Give me download url please.', PHP_EOL; | |
exit; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deb http://ftp.sjtu.edu.cn/ubuntu/ trusty main restricted universe multiverse | |
deb http://ftp.sjtu.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse | |
deb http://ftp.sjtu.edu.cn/ubuntu/ trusty-security main restricted universe multiverse | |
deb-src http://ftp.sjtu.edu.cn/ubuntu/ trusty main restricted universe multiverse | |
deb-src http://ftp.sjtu.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse | |
deb-src http://ftp.sjtu.edu.cn/ubuntu/ trusty-security main restricted universe multiverse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/^(170[059]\d{7}|(14[57]|15[^4,\D]|17[678])\d{8}|1[38]\d{9})$/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git branch --merged=develop | grep -v 'master' | grep -v 'develop' | tr -d '^ ' | xargs git branch -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
if (count($argv) == 1) { | |
throw new InvalidArgumentException('Missing tables'); | |
} | |
$tables = array_slice($argv, 1); | |
$db = new PDO('mysql:dbname=uniqueway_development;host=127.0.0.1;charset=utf8mb4', 'root', ''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Faker | |
class PhoneNumber < Base | |
class << self | |
def cell_phone | |
operators = [ | |
134, 135, 136, 137, 138, 139, 147, 150, 151, 152, 157, 158, 159, 182, 187, 188, # china mobile | |
130, 131, 132, 145, 155, 156, 185, 186, 145, # china unicom | |
133, 153, 180, 181, 189 # china telecom | |
] | |
suffix = Random.rand(10000000...99999999) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function proxy() { | |
proxy_on | |
$@ | |
proxy_off | |
} | |
function proxy_on() { | |
export all_proxy="http://127.0.0.1:1087" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'elasticsearch/rails/tasks/import' | |
namespace :elasticsearch do | |
desc 'Rebuild index with zerodown time' | |
task rebuild: :environment do | |
size = (ENV['size'].presence || 1000).to_i | |
model = ENV['model'].to_s.classify.constantize | |
delete_old_index = ENV['delete'].present? | |
es = model.__elasticsearch__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('ENCRYPTION_KEY', 'EncryptDecryptPHP201908Y'); | |
// Encrypt | |
function encrypt($plaintext) { | |
$ivlen = openssl_cipher_iv_length($cipher = "AES-128-CBC"); | |
$iv = openssl_random_pseudo_bytes($ivlen); | |
$ciphertext_raw = openssl_encrypt($plaintext, $cipher, ENCRYPTION_KEY, $options = OPENSSL_RAW_DATA, $iv); | |
$hmac = hash_hmac('sha256', $ciphertext_raw, ENCRYPTION_KEY, $as_binary = true); |
OlderNewer