Skip to content

Instantly share code, notes, and snippets.

View asika32764's full-sized avatar

Simon Asika asika32764

View GitHub Profile
/*
* 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 January 28, 2024 19:44
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
@asika32764
asika32764 / add_composer.xml
Created July 4, 2015 13:33
Add Composer to OpenCart 2.0
<modification>
<id>Add composer</id>
<version>1.0</version>
<vqmver>1.0.8</vqmver>
<author>Simon Asika</author>
<file name="system/startup.php">
<operation>
<search position="after"><![CDATA[
require_once(DIR_SYSTEM . 'helper/utf8.php');
]]></search>
<?php
class BlogRouter extends JComponentRouterBase
{
public function build(&$queries)
{
$segments = array();
$params = array(
'view',
<?php
// Get Base URI
$baseUri = str_replace($_SERVER['DOCUMENT_ROOT'], '', dirname($_SERVER['SCRIPT_FILENAME']));
$http = str_replace(array('/', '\\'), '/', $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . $baseUri . '/');
$catalog = explode('/', $http);
array_pop($catalog);
array_pop($catalog);
$catalog = implode('/', $catalog) . '/';