Skip to content

Instantly share code, notes, and snippets.

View asika32764's full-sized avatar

Simon Asika asika32764

View GitHub Profile
<?php
ini_set('display_errors', true); error_reporting(-1); // <- for debugging purposes only
$socket=socket_create(AF_INET, SOCK_RAW, SOL_TCP);
if ( !$socket ) {
$errno = socket_last_error();
$error = sprintf('%s (%d)', socket_strerror($errno), $errno);
trigger_error($error, E_USER_ERROR);
}
<?php
include("./php-AES.php");
$z = "abcdefgh01234567"; // 128-bit key
//$z = "abcdefghijkl012345678901"; // 192-bit key
//$z = "abcdefghijuklmno0123456789012345"; // 256-bit key
$aes = new AES($z);
$data = file_get_contents("./example.txt");
<?php
// components/com_flower/model/sakura.php
// Model
class FlowerModelSakura extends \Windwalker\Model\CrudModel
{
// CrudModel will auto getForm()
}
// Then add components/com_flower/model/form/sakura.xml
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity
@asika32764
asika32764 / sanfrancisco-font.css
Created November 30, 2015 18:24
San Francisco Web Font
/**
* http://applemusic.tumblr.com/
* https://jsfiddle.net/xq56dmrh/
*/
/** Ultra Light */
@font-face {
font-family: "San Francisco";
font-weight: 100;
src: url("https://applesocial.s3.amazonaws.com/assets/styles/fonts/sanfrancisco/sanfranciscodisplay-ultralight-webfont.woff");
@asika32764
asika32764 / github-oauth2-client.php
Last active March 12, 2025 13:49
Simple PHP example of using Github's OAuth 2 API. (Please see comments for PHP 8.1 later and latest API version.)
<?php
define('OAUTH2_CLIENT_ID', '');
define('OAUTH2_CLIENT_SECRET', '');
$authorizeURL = 'https://github.com/login/oauth/authorize';
$tokenURL = 'https://github.com/login/oauth/access_token';
$apiURLBase = 'https://api.github.com/';
session_start();

View Setting

Note: the $data object in ApiView is Registry not Data object, we must use set() to set data.

Component is com_flower, view is sakuras.

// components/com_flower/view/sakuras/json.php
@asika32764
asika32764 / ffmpeg-preview.sh
Created July 31, 2015 03:33
Create Video preview image
ffmpeg -i /path/to/video.mp4 -ss 00:00:5 -vframes 1 -y /path/to/preview.png
<?php
/**
* Part of Ezset project.
*
* @copyright Copyright (C) 2015 {ORGANIZATION}. All rights reserved.
* @license GNU General Public License version 2 or later;
*/
namespace MyEzset\Listener\ModuleRedirect;

Windwalker RAD Simple ORM 簡易說明

這是一個簡易的 Relation 配置功能,可以讓 Table 或 DataMapper 在操作單一張表的時候,有能力根據需求讀取或修改對應的關聯表。

簡易一對多範例

假設有一張表 foo 對應多個 sakuras 與 roses 的表,sakuras 與 roses 各有一個 foo_id 欄位對應到 foos 表的 id。此即一對多關係。

<?php