Skip to content

Instantly share code, notes, and snippets.

View yookoala's full-sized avatar

Koala Yeung yookoala

  • Pixel Action Studio
  • Hong Kong
  • 10:02 (UTC +08:00)
View GitHub Profile
@yookoala
yookoala / index.php
Created September 26, 2018 08:20
FormData javascript API test
<?php
/**
* A very simple test of FormData API with a very simple
* PHP backend.
*
* Usage:
*
* 1. Save this file to a folder.
* 2. Open your terminal and cd to this folder.
@yookoala
yookoala / http_parse_response_header.php
Created August 29, 2018 04:51
Parse the side effect variable $http_response_header of file_get_contents().
<?php
/**
* http_parse_response_header()
* Parse $http_response_header produced by file_get_contents().
*
* @param array $header
* Supposed $http_response_header or array alike.
* @param array
* Assoc array of the parsed version.
@yookoala
yookoala / example.php
Last active June 16, 2019 15:25 — forked from hklcf/Screenshot via Google PageSpeed API
Screenshot via Google PageSpeed API
<?php
include_once 'getGooglePageSpeedScreenshot.php';
echo getGooglePageSpeedScreenshot($_GET['url']);
// Output: <img src="..." border="1" style="width: 80px; height: 80px" />
echo getGooglePageSpeedScreenshot($_GET['url'], [
'class' => 'thumbnail',
'style' => ['width: 80px;', 'height: 80px;']
@yookoala
yookoala / http_build_attribute.php
Last active January 17, 2025 10:18
Build HTML tag attributes with a given array.
<?php
/**
* Build HTML tag attributes string with a given array.
*
* Usage Example:
* echo '<img ' . http_build_attributes([
* 'src' => 'some-image-url',
* 'class' => ['img-responsive', 'decorative'],
* ]);
@yookoala
yookoala / tick5.spec
Last active April 16, 2020 10:01
SPEC file refactored with macro
# Variables that might be modified by maintainer easily.
%define name tick5
%define version 0.1
%define release 1
%define systemdinstalldir /etc/systemd/system
%define message come on, James
# Some metadata required by an RPM package
Name: %name
Summary: Print a message every 5s
@yookoala
yookoala / control
Last active July 26, 2018 11:11
A debian package control file example
Package: tick5
Maintainer: Koala Yeung
Architecture: all
Version: 0.1
Description: Print a message every 5s
.
tick5 is a simple useless script that echos a message every 5 seconds.
@yookoala
yookoala / tick5.spec
Last active April 16, 2020 09:53
SPEC for tick5 with systemd unit.
# Some metadata required by an RPM package
Name: tick5
Summary: Print a message every 5s
Version: 0.1
Release: 1
License: MIT
%description
tick5 is a simple useless script that echos a message every 5 seconds.
@yookoala
yookoala / tick5.service
Last active July 26, 2018 06:35
systemd unit file for tick5.service
[Unit]
StopWhenUnneeded=true
[Install]
WantedBy=multi-user.target
[Service]
ExecStart=/usr/bin/tick5
Restart=always
RestartSec=5
@yookoala
yookoala / tick5.spec
Last active July 26, 2018 05:57
RPM SPEC file for tick5
# Some metadata required by an RPM package
Name: tick5
Summary: Print a message every 5s
Version: 0.1
Release: 1
License: MIT
%description
tick5 is a simple useless script that echos a message every 5 seconds.
@yookoala
yookoala / tick5
Last active July 27, 2018 12:57
A very simple bash script for fun.
#!/bin/bash
# say something, with timestamp, every 5 seconds
while echo "$@"; do
sleep 5s
done