Skip to content

Instantly share code, notes, and snippets.

🐟
摸鱼中

PRIN.T printempw

🐟
摸鱼中
Block or report user

Report or block printempw

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@printempw
printempw / sum.php
Created Jan 10, 2017
Calculate the total number of comments posted last year from Diqus exported XML file.
View sum.php
<?php
/**
* @Author: printempw
* @Date: 2017-01-10 22:44:20
* @Last Modified by: printempw
* @Last Modified time: 2017-01-10 23:09:35
*/
$xmlString = file_get_contents('./blessing-studio-2017-01-10T14_38_39.483395-all.xml');
@printempw
printempw / 1-nginx-vhost-template.conf
Created Jan 7, 2017
Template for creating new nginx vhost.
View 1-nginx-vhost-template.conf
server {
listen 443 ssl http2;
server_name your-domain.com www.your-domain.com;
index index.html index.htm index.php;
# Let's Encrypt Certificate
ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;
ssl_session_timeout 10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
@printempw
printempw / nginx.conf
Created Dec 25, 2016
Chereveto rewrite rules for Nginx
View nginx.conf
location / {
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
@printempw
printempw / page.html
Created Dec 17, 2016
Click button to load Disqus
View page.html
<a class="btn btn-default" href="javascript:disqus.load();">点击以加载 Disqus</a>
@printempw
printempw / index.html
Created Nov 26, 2016
PHP Remote Download with Progress Bar [Frontend]
View index.html
<p>更新包大小:<span id="file-size">0</span> Bytes</p>
<!-- 进度条 -->
<div class="progress">
<div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
<span id="imported-progress">0</span>%
</div>
</div>
<script>
// 更新进度条的函数
@printempw
printempw / download.php
Created Nov 26, 2016
PHP Remote Download with Progress Bar [Backend]
View download.php
<?php
// 当前文件:download.php
$action = @$_GET['action'];
// 自己获取这些信息
$remote_url = get_remote_file_url();
$file_size = get_remote_file_size($remote_url);
$tmp_path = get_tmp_path();
View dynamically-load-gist.js
$('.load-gist').on('click', function() {
var gist = {
// URL 传参自己改下
url: '//gist.github.com/printempw/' + $(this).data('hash') + '.json?callback=?',
dom: this
}
// 因为 URL 中带了 `callback=?`,所以这里 jQuery 会使用 JSONP 方式请求
$.getJSON(gist.url, function(data) {
// 加载样式
View PluginServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Support\Str;
use App\Services\PluginManager;
use Illuminate\Support\ServiceProvider;
class PluginServiceProvider extends ServiceProvider
{
View plugin-autoload.php
<?php
public function boot(PluginManager $plugins)
{
// store paths of class files of plugins
$src_paths = [];
foreach ($plugins->getPlugins() as $plugin) {
$src_paths[$plugin->getNameSpace()] = $plugin->getPath()."/src";
}
View PluginManager.php
<?php
namespace App\Services;
use Illuminate\Support\Arr;
use App\Events\PluginWasEnabled;
use App\Events\PluginWasDisabled;
use Illuminate\Support\Collection;
use App\Events\PluginWasUninstalled;
use Illuminate\Filesystem\Filesystem;
You can’t perform that action at this time.