Multipart Upload with PHP
About
This is a simple example to do a "multipart/form-data" POST request in PHP without any fancy library.
<?php | |
/** | |
* Extract HTML children of a give tag name from a given document. | |
* | |
* @param \DOMDocument $doc The DOM document to extract from. | |
* @param string $tagName The tag name for extraction (e.g. 'head', 'body') | |
* | |
* @return \DOMDocument An DOMElement containing all child elements from the tag specified in $dom. | |
*/ |
# | |
# Save this file as: /etc/systemd/system/battery-level-check.service | |
# | |
[Unit] | |
Description=Battery check. If higher than 80% or lower than 40%, notify desktop user | |
Wants=battery-level-check.timer | |
[Service] | |
Type=simple |
class DummyParent { | |
static hello() { | |
console.log('dummy parent say hello') | |
} | |
} | |
class Dummy extends DummyParent { | |
static foo() { | |
console.log('dummy say foo') | |
} |
<?php | |
namespace Monogatari\RemoteStorage; | |
/** | |
* Throw this if a key is not found in a StorageInterface. | |
*/ | |
class StorageKeyNotFound extends \Exception | |
{ | |
/** |
# | |
# Apple SuperDrive initialization rule | |
# | |
# See: https://gist.github.com/yookoala/818c1ff057e3d965980b7fd3bf8f77a6 | |
ACTION=="add", ATTRS{idProduct}=="1500", ATTRS{idVendor}=="05ac", DRIVERS=="usb", RUN+="/usr/bin/sg_raw %r/sr%n EA 00 00 00 00 00 01" |
<?php | |
/** | |
* @file | |
* | |
* Mock Sendmail | |
* | |
* A small script to be used as sendmail for debugging mailing functions in php. | |
* | |
* Usage: |
This is a simple example to do a "multipart/form-data" POST request in PHP without any fancy library.
#!/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> |
<?php | |
/** | |
* This works. | |
*/ | |
$a = 1; $b = 2; | |
echo "Before swap: {$a}, {$b}\n"; | |
list($a, $b) = [$b, $a]; | |
echo "After swap: {$a}, {$b}\n"; |
# 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 |