This is a simple example to do a "multipart/form-data" POST request in PHP without any fancy library.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BASENAME=$(basename $0) | |
BASEPATH=$(dirname $(realpath $0)) | |
# Print usage message | |
function usage { | |
cat <<EOF | |
usage: $BASENAME -k <GITHUB_API_TOKEN> -r <GITHUB_REPO_SLUG> -t <TAG> <DIST_PATH> <LABEL> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This works. | |
*/ | |
$a = 1; $b = 2; | |
echo "Before swap: {$a}, {$b}\n"; | |
list($a, $b) = [$b, $a]; | |
echo "After swap: {$a}, {$b}\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Variables that can be override on build time. | |
%{!?sleep: %define sleep 5} | |
%{!?name: %define name tick%{sleep}} | |
%{!?version: %define version 0.0} | |
%{!?release: %define release 1} | |
%{!?systemdinstalldir: %define systemdinstalldir /etc/systemd/system} | |
%{!?message: %define message come on, James} | |
# Some metadata required by an RPM package | |
Name: %name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# A collection of high-level-ish functions for | |
# bash pipeline operations. | |
# breakdown the output of ls or find into one | |
# item per line in STDOUT for pipeline. | |
# | |
# Usage: | |
# ls . | breakdown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# map the data output from CLI tools like ls or find | |
# to execute action on each result. | |
# | |
# Example Usages: | |
# map <FUNCNAME or CLI COMMAND> "$(find ./some-folder -mindepth 1)" | |
# or | |
# find ./some-folder -mindepth 1 | map <FUNCNAME or CLI COMMAND> | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Note: Some authentication logics should be here! | |
// Setup enviroment | |
header('Content-Disposition: attachment; filename="backup.sql"'); | |
ini_set('display_errors', 1); | |
ini_set('display_startup_errors', 1); | |
ini_set('max_execution_time', 0); // disable execution time limit | |
error_reporting(E_ALL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func merge(cs ...<-chan int) <-chan int { | |
out := make(chan int) | |
var cases []reflect.SelectCase | |
for _, c := range chans { | |
cases = append(cases, reflect.SelectCase{ | |
Dir: reflect.SelectRecv, | |
Chan: reflect.ValueOf(c), | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "yookoala/htmlpurifier-example", | |
"authors": [ | |
{ | |
"name": "Koala Yeung", | |
"email": "koalay at gmail dot com" | |
} | |
], | |
"require": { | |
"ezyang/htmlpurifier": "^4.10" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: messages.po | |
clean: | |
rm -f messages.po | |
.PHONY: all clean | |
messages.po: | |
xgettext \ | |
--language=PHP \ |