Skip to content

Instantly share code, notes, and snippets.

View prinsss's full-sized avatar
🐟
摸鱼中

prin prinsss

🐟
摸鱼中
  • The profile picture is an illustration created by sakumaru.
View GitHub Profile
@prinsss
prinsss / example.php
Created July 12, 2016 03:55
PHP function reload example
<?php
class Shit
{
/**
* Function reload
*/
public static function fuck()
{
$args = func_get_args();
@prinsss
prinsss / aplayer.js
Last active July 25, 2016 06:58
Generate playlist config for APlayer from netease music automatically
/*
* @Author: printempw
* @Date: 2016-07-25 13:03:12
* @Last Modified by: printempw
* @Last Modified time: 2016-07-25 14:51:29
*/
var superagent = require('superagent');
// fill your ids here
@prinsss
prinsss / isEmpty.js
Created September 16, 2016 04:37
Check if given object empty.
function isEmpty(obj) {
// null and undefined are "empty"
if (obj == null) return true;
// Assume if it has a length property with a non-zero value
// that that property is correct.
if (obj.length > 0) return false;
if (obj.length === 0) return true;
<?php
namespace App\Services;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Contracts\Support\Arrayable;
/**
* @property string $name
<?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;
<?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";
}
<?php
namespace App\Providers;
use Illuminate\Support\Str;
use App\Services\PluginManager;
use Illuminate\Support\ServiceProvider;
class PluginServiceProvider extends ServiceProvider
{
$('.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) {
// 加载样式
@prinsss
prinsss / download.php
Created November 26, 2016 09:54
PHP Remote Download with Progress Bar [Backend]
<?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();
@prinsss
prinsss / index.html
Created November 26, 2016 10:07
PHP Remote Download with Progress Bar [Frontend]
<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>
// 更新进度条的函数