Skip to content

Instantly share code, notes, and snippets.

View asika32764's full-sized avatar

Simon Asika asika32764

View GitHub Profile
@Cojad
Cojad / mini_google_authenticator.php
Last active July 5, 2023 09:15
Very small implementation of Google's OTP Authenticator
<?php
// copied from python code at https://stackoverflow.com/a/23221582/3103058
function base32_decode($key) {
// https://www.php.net/manual/en/function.base-convert.php#122221
$key = strtoupper($key);
list($t, $b, $r) = array("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", "", "");
foreach(str_split($key) as $c)
$b = $b . sprintf("%05b", strpos($t, $c));
foreach(str_split($b, 8) as $c)
$r = $r . chr(bindec($c));
@franksacco
franksacco / session-handler-life-cycle.md
Last active April 5, 2024 16:41
A complete overview of PHP session handler life cycle

A complete overview of PHP session handler life cycle

The purpose of this document is to provide a complete overview of the PHP session handler life cycle updated to version 7.0 or above. In particular, I want to emphasize what methods and in what order are called when the native PHP functions are used for session management.
I created this document because the information on the web and the official documentation are very superficial on this topic, in particular on what concerns the implementation of a safe and stable session handler.

@ManasN
ManasN / 3D Particles forming shapes.markdown
Created September 12, 2015 10:10
3D Particles forming shapes

3D Particles forming shapes

My first take at a 3D particle system. Using three.js the particles jump between having targets in a sphere shape and a (filled) box shape.

A Pen by Pål Smitt-Amundsen on CodePen.

License.

@eduardomello
eduardomello / preg_replace_test.php
Created March 9, 2015 17:43
use of PHP preg_replace() to add basepath to src and href
<?php
/*
* Script that shows how to insert a basepath on HTML tags
* It looks for link, script and img tags that do not contain the
* determined basepath or a external URL
*/
// BasePath to insert in string when necessarry
$basePath = "/project/site/";
$escapedBasePath = str_replace("/", "\/", $basePath);
@ccckmit
ccckmit / gist:b0a90a7bd9d3d3e5baa8
Last active August 29, 2015 14:16
javascript version of enigma machine (in world war II)
// 原始程式來源: http://practicalcryptography.com/ciphers/enigma-cipher/ 網頁內的 javascript 程式碼
var c = console;
var plaintext = 'ABCDEF';
c.log('>> plaintext2 : '+plaintext);
var ciphertext = Encrypt(plaintext, 'AAA', 'AAA', '123', 'POMLIUKJNHYTGBVFREDC');
c.log('>> ciphertext : '+ciphertext);
var plaintext2 = Encrypt(ciphertext, 'AAA', 'AAA', '123', 'POMLIUKJNHYTGBVFREDC');
c.log('>> plaintext2 : '+plaintext);
@sanderpotjer
sanderpotjer / edit.php
Last active May 5, 2023 03:08
Template override for improved Joomla article submission form
<?php
/**
* @package Article Form override for Joomla 3
* @copyright Copyright (c) 2014 Sander Potjer - www.perfectwebteam.nl
* @license GNU General Public License version 3 or later
*/
defined('_JEXEC') or die;
JHtml::_('behavior.keepalive');
@asika32764
asika32764 / get-pr
Last active June 12, 2017 08:36
An easy way to help you get single Pull-Request from GitHub
#!/usr/bin/env bash
git fetch $1 refs/pull/$2/head:pr-$2
@edokeh
edokeh / index.js
Last active April 18, 2024 08:07
佛祖保佑,永无 BUG
//
// _oo0oo_
// o8888888o
// 88" . "88
// (| -_- |)
// 0\ = /0
// ___/`---'\___
// .' \\| |// '.
// / \\||| : |||// \
// / _||||| -:- |||||- \
@koenpunt
koenpunt / chosen-bootstrap.css
Last active March 11, 2023 01:01
Bootstrap 3.0 theme for Chosen
select.form-control + .chosen-container.chosen-container-single .chosen-single {
display: block;
width: 100%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.428571429;
color: #555;
vertical-align: middle;
background-color: #fff;
@davidou123
davidou123 / TaiwanStreetName
Created March 12, 2013 15:21
這是一份台灣街道的資料 內容格式為[排序序號][郵遞區號三碼][縣市][鄉鎮市][路名] 資料來源來自於綠奶茶blog整理(http://milkmidi.blogspot.tw/2012/03/blog-post.html) ------------------------------------------------- 而他的資料來源是從中華郵政api撈出來的 http://www.post.gov.tw/post/internet/f_searchzone/streetNameData.jsp (直接點是無效的, 請用任意程式用 POST傳值) city:臺北市 cityarea:信義區 就會得到該區的街道XML
This file has been truncated, but you can view the full file.
-- phpMyAdmin SQL Dump
-- version 2.10.3
-- http://www.phpmyadmin.net
--
-- 主機: localhost
-- 建立日期: Mar 12, 2013, 03:16 PM
-- 伺服器版本: 5.0.51
-- PHP 版本: 5.2.6
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";