Skip to content

Instantly share code, notes, and snippets.

View ayonliu's full-sized avatar

Lyon Liu ayonliu

View GitHub Profile
@ayonliu
ayonliu / geodistance.php
Created June 9, 2014 09:49
Calculate distance between two locations
<?php
/*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
/*:: :*/
/*:: This routine calculates the distance between two points (given the :*/
/*:: latitude/longitude of those points). It is being used to calculate :*/
/*:: the distance between two locations using GeoDataSource(TM) Products :*/
/*:: :*/
/*:: Definitions: :*/
/*:: South latitudes are negative, east longitudes are positive :*/
@ayonliu
ayonliu / global.php
Last active August 29, 2015 14:02
Register The Laravel Class Loader without Composer updating.
<?php
/*
| path: app/start/global.php
|--------------------------------------------------------------------------
| Register The Laravel Class Loader
|--------------------------------------------------------------------------
|
| In addition to using Composer, you may use the Laravel class loader to
| load your controllers and models. This is useful for keeping all of
@ayonliu
ayonliu / HessianClient.php
Created June 12, 2014 10:19
How to use HessianPHP
<?php
include 'src/HessianClient.php';
$fp = fopen(dirname(__FILE__).'/unit_tests/ok.png', "r");
$options = new HessianOptions();
$options->version = 2;
$options->transport = "http";
// hessian server address
@ayonliu
ayonliu / HomeController.php
Created June 12, 2014 11:25
How to use hessian in laravel
<?php
// app/controllers/HomeController.php
class HomeController extends BaseController {
// method for client to call
function getFile($file)
{
return $file . ' hessian';
//return $file;
@ayonliu
ayonliu / NewCommand.php
Created June 17, 2014 02:28
Create command in Laravel
<?php
// app/commands/NewCommand.php
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class NewCommand extends Command {
/**
@ayonliu
ayonliu / ln.sh
Last active August 29, 2015 14:02
Add virtual host for nginx under Ubuntu
# build soft link between files under sites-available and sites-enabled
ln -s /etc/nginx/sites-available/test.com /etc/nginx/sites-enabled/test.com
service nginx restart
@ayonliu
ayonliu / godoc.md
Created June 17, 2014 06:37
Golang docs

查看某一个buildin包里面的函数:godoc buildin,例如查看http包文档,那么执行: godoc net/http 执行 godoc fmt Printf, 可以查看相应的代码 执行 godoc -src fmt Printf, 可以查看相应的代码

通过命令在命令行执行 godoc -http=:端口号 比如godoc -http=:8080。然后在浏览器中打开127.0.0.1:8080,你将会看到一个golang.org的本地copy版本

@ayonliu
ayonliu / var.go
Last active August 29, 2015 14:02
Golang variable define
Go语言里面定义变量有多种方式。
使用var关键字是Go最基本的定义变量方式,与C语言不同的是Go把变量类型放在变量名后面:
//定义一个名称为“variableName”,类型为"type"的变量
var variableName type
定义多个变量
//定义三个类型都是“type”的三个变量
var vname1, vname2, vname3 type
@ayonliu
ayonliu / add-ftp-user.sh
Last active August 29, 2015 14:02
Add ftp user
# assume vsftpd installed
# add a user called `ftpuser`, home dir is "/var/www/html/example.com"
useradd -d /var/www/html/example.com -s /usr/sbin/nologin ftpuser
# add passowrd for ftpuser
passwd ftpuser
#
chown -R ftpuser:ftpuser /var/www/html/example.com
@ayonliu
ayonliu / function.php
Created June 27, 2014 09:44
Laravel 4 – Get Path to App, Public, Storage and Base Install Directories
<?php
/**
* Path to the 'app' folder
*/
echo app_path();
/**
* Path to the project's root folder
*/
echo base_path();
/**