Skip to content

Instantly share code, notes, and snippets.

@eddy8
eddy8 / autowrite.php
Created April 1, 2017 07:30
Symfony DependencyInjection Autowire
<?php
namespace Eddy;
use Symfony\Component\DependencyInjection\Compiler\AutowirePass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
require 'vendor/autoload.php';
@eddy8
eddy8 / laravel_queue_standalone.php
Created March 14, 2017 08:18
laravel queue(v5.3) standalone with redis
<?php
use Illuminate\Queue\Capsule\Manager as Queue;
use Illuminate\Redis\Database as Redis;
require 'vendor/autoload.php';
$queue = new Queue;
$app = $queue->getContainer();
$manager = $queue->getQueueManager();
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [null, ''])[1].replace(/\+/g, '%20')) || null;
}
<?php
ignore_user_abort(true);
set_time_limit(0); // disable the time limit for this script
$path = "/absolute_path_to_your_files/"; // change the path to fit your websites document structure
$dl_file = preg_replace("([^\w\s\d\-_~,;:\[\]\(\].]|[\.]{2,})", '', $_GET['download_file']); // simple file name validation
$dl_file = filter_var($dl_file, FILTER_SANITIZE_URL); // Remove (more) invalid characters
$fullPath = $path.$dl_file;
@eddy8
eddy8 / webservice.frm
Created May 23, 2014 08:09
vb6 use java webservice with post and soap
Private Sub Command1_Click()
Dim strSoapAction As String
Dim strUrl As String
Dim strxml As String
Dim returnMsg As String
strUrl = "http://xxx.com/xxx"
strSoapAction = "http://yyy.com/zzz"
@eddy8
eddy8 / dec2bin.php
Created April 29, 2014 03:10
dec to bin
<?php
/**
* 不用内置函数自己实现十进制转二进制
* @param integer $num 十进制数
* @return string 二进制字符串
*/
function my_dec2bin($num){
if(!is_integer($num)){
return '';
}
@eddy8
eddy8 / url_exist.php
Last active August 29, 2015 14:00
check url exist
<?php
/**
* 判断URL是否存在/可访问
* @param string $url url
* @return bool 存在返回true。不存在返回false
*/
function url_exist($url){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
@eddy8
eddy8 / ping.php
Created October 16, 2013 02:41
php ping
<?php
/**
*@param $domain string IP address or URL
*/
function pingDomain($domain){
$data = parse_url($domain);
if (isset($data['host'])) {
$domain = $data['host'];
}else{
$domain = $data['path'];
<?php
$x = function($bar, $foo="9") {
echo $foo, $bar, "\n";
};
class MissingArgumentException extends Exception {
}
function call_user_func_named_array($method, $arr){
@eddy8
eddy8 / time_of_a_week_ago.php
Last active December 19, 2015 09:19
获取一周前的时间
<?php
function a_week_ago(){
$today = getdate();
$start_time = mktime(0,0,0,$today['mon'],$today['mday']-7,$today['year']);
$end_time = time();
}