Skip to content

Instantly share code, notes, and snippets.

View asika32764's full-sized avatar

Simon Asika asika32764

View GitHub Profile
@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);
@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
@rlemon
rlemon / gist:1780212
Created February 9, 2012 14:12
PHP get CPU information from /proc/stat
<?php
/* Gets individual core information */
function GetCoreInformation() {
$data = file('/proc/stat');
$cores = array();
foreach( $data as $line ) {
if( preg_match('/^cpu[0-9]/', $line) )
{
$info = explode(' ', $line );
$cores[] = array(
@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);
@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;
@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');
@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));
@Synchro
Synchro / gist:1139429
Created August 11, 2011 11:29
PHP Base-62 encoder/decoder
<?php
/**
* This is an example of a practical encoder and decoder for base-62 data in PHP
* It differs from the majority of examples in that it's fast enough for moderate data sizes, unlike multiprecision converters
* To be practical, base-62 encoding needs to use internal chunking and padding because base-62 does not fit exactly into any integral number of bits
* This means the output is not quite compatible with multiprecision conversions,
* but the encoded data retains all the desirable properties of base-62, so (unlike any base-64 encoding) it's URL, DNS, email address and pathname safe
* @author Marcus Bointon <marcus@synchromedia.co.uk>
* @copyright 2011 Marcus Bointon
* @license http://www.opensource.org/licenses/mit-license.html MIT License
@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";