Skip to content

Instantly share code, notes, and snippets.

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

prin prinsss

🐟
摸鱼中
View GitHub Profile
@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();
$('.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) {
// 加载样式
<?php
namespace App\Providers;
use Illuminate\Support\Str;
use App\Services\PluginManager;
use Illuminate\Support\ServiceProvider;
class PluginServiceProvider extends ServiceProvider
{
<?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\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
namespace App\Services;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Contracts\Support\Arrayable;
/**
* @property string $name
@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;
@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 / 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 / click-game.css
Last active November 3, 2016 05:02
Click the element to show a "+1" animation and change the content of the element to a new kaomoji. Just for fun :)
#kaomoji {
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
}
.info-rise {
z-index: 99999;
position: absolute;
padding: 0 4px;
border-radius: 1px;