Skip to content

Instantly share code, notes, and snippets.

View duan-li's full-sized avatar

D Li duan-li

View GitHub Profile
for ($i=1; $i<=128; $i+=25)
{
$url = "https://gdata.youtube.com/feeds/api/playlists/_PLAYLIST_ID_?start-index=$i&amp;max-results=150&amp;v=2";
$file = file_get_contents ($url);
$arr = xml2array($file);
foreach($arr['feed']['entry'] as $e)
{
function ucwords (str) {
// http://kevin.vanzonneveld.net
// + original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
// + improved by: Waldo Malqui Silva
// + bugfixed by: Onno Marsman
// + improved by: Robin
// + input by: James (http://www.james-bell.co.uk/)
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// * example 1: ucwords('kevin van zonneveld');
// * returns 1: 'Kevin Van Zonneveld'
@duan-li
duan-li / compress_each.bat
Created October 8, 2014 23:45
compress each file to each package.
for %f in ("C:\Bob\WithBlank\NeuerOrdner3\*.txt") do (
"C:\WINDOWS\7za.exe" a -t7z "%~dpnf.7z" "%~ff"
)

平台:DigitalOcean VPS ubuntu14.04 x64, strongswan5.2.2 运行以下命令请使用root权限

一:安装strongswan

由于ubuntu软件仓库中strongswan版本较低,因此从官网源码编译安装

apt-get install build-essential     #编译环境
aptitude install libgmp10 libgmp3-dev libssl-dev pkg-config libpcsclite-dev libpam0g-dev     #编译所需要的软件
@duan-li
duan-li / initial_l2tpd.sh
Created May 29, 2015 08:43
ubuntu 14.04 LTS ipsec & l2tpd server setup
#!/bin/bash
# ref https://raymii.org/s/tutorials/IPSEC_L2TP_vpn_with_Ubuntu_14.04.html
echo "Type a VPN Username:"
read VPN_USER
echo "Type a VPN Password:"
read VPN_PASSWORD
echo "Type a Pre-Shared key(As long as possible)"
read IPSEC_PSK
@duan-li
duan-li / initial_lnhp.sh
Last active August 29, 2015 14:22
Ubuntu 14.04 LTS nginx HHVM and php-fpm fallback setup
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
CURRENT_USER=$(id -u -n)
CURRENT_GROUP=$(id -g -n)
CURRENT_USER_HOME=$(eval echo ~${SUDO_USER})
if [ -n "${SUDO_USER}" ]; then
@duan-li
duan-li / initial_percona_tokudb.sh
Last active August 10, 2017 07:30
Ubuntu 14.04 LTS Percona server and TokuDB setup
#!/bin/bash
# ref-main: https://www.percona.com/doc/percona-server/5.5/installation/apt_repo.html
# ref-main: https://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_installation.html
# ref: https://www.digitalocean.com/community/tutorials/how-to-install-a-fresh-percona-server-or-replace-mysql
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
echo "Type your percona server root pasword:"
@duan-li
duan-li / send_get_with_header.php
Created July 5, 2015 23:42
send get request with header. Without curl
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Content-Type: application/json\r\n" .
"X-User-Email: someone@email.com\r\n" .
"X-Auth-Token: some_auth_token\r\n"
)
);
$context = stream_context_create($opts);
@duan-li
duan-li / post_json_code.php
Created July 5, 2015 23:46
post json request with
$url = "http://your_api_address.com";
$json = '
{"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
@duan-li
duan-li / initial_lamp.sh
Last active August 21, 2022 19:07
Ubuntu 14.04 LTS apache php-fpm setup
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
CURRENT_USER=$(id -u -n)
CURRENT_GROUP=$(id -g -n)
CURRENT_USER_HOME=$(eval echo ~${SUDO_USER})