Skip to content

Instantly share code, notes, and snippets.

View KennFatt's full-sized avatar
🌠
Stargazing

Kennan Fattahillah KennFatt

🌠
Stargazing
View GitHub Profile
@KennFatt
KennFatt / Dummy.lua
Created February 16, 2019 08:23
Lua initialized code-race proof.
Dummy = {}
local initialized = false
function Dummy:init()
if not initialized then
initializied = true
return initialized
else
return nil
@KennFatt
KennFatt / JuzAmma.js
Created February 10, 2019 10:54
Easy way to learning Juz-Amma (Al-Qur'an).
let at_takasur = {
verseLength: 8,
verse: [
"Alhakumut takasur",
"Hatta zurtumu maqabir",
"Kalla saufa ta'lamun",
"Summa kalla saufa ta'lamun",
"Kalla lau ta'lamuna ilmal-yaqin",
"Latarawinnal-jahim",
"Summa latarawunnaha ainal-yaqin",
@KennFatt
KennFatt / count_table.lua
Created February 9, 2019 16:37
Lua count any kind of table
local params = {
["owner_name"] = "MeAsOwner",
["delay_time"] = 30,
["iterator"] = 1,
["handler"] = function() return 0 end,
}
local count = 0
for _ in pairs(params) do
count = count + 1
@KennFatt
KennFatt / RGBtoCCP.lua
Last active January 24, 2019 10:40
Convert RGB value into Corona SDK's Palette Colour
-- This is a script that convert RGB value into Corona Color Palette (CCP).
-- A RGB color has max value = 255 and that means 1 value for CCP.
-- ______________________
-- |RGB | CCP |
-- |_________|___________|
-- | 255 | 1 |
-- | 0 | 0 |
-- |_________|___________|
@KennFatt
KennFatt / toIco.php
Created December 30, 2018 12:02
Rename .png into .icon. Basically just that. You can modify into your own cases.
<?php
declare(strict_types=1);
// configurable
const EXT = ".ico";
foreach (scandir(__DIR__) as $aa => $bb) {
if ($bb == "." || $bb == ".." || $bb == "toIco.php") continue;
$a = base64_encode(file_get_contents($bb));
@KennFatt
KennFatt / date.cpp
Created September 2, 2018 06:05 — forked from dibakarsutradhar/date.cpp
A date program using struct
#include <iostream>
using namespace std;
struct DateStruct {
int year;
int month;
int day;
};
<?php
/**
* WARNING: Keep your machine safe! This is just for testing purpose.
*
* ini_set("memory_limit", -1); or you can set it manually in php.ini
*/
declare(strict_types=1);
@KennFatt
KennFatt / ZendMMTest.php
Last active August 30, 2018 11:39
Testing PHP's Zend Memory Manager
<?php
/**
* Testing Zend Memory Manager.
*
* Testing allocated segments in Kilobytes
*/
$m = (float) (memory_get_usage(true) / 1024);
@KennFatt
KennFatt / SplClassLoader.php
Created May 5, 2018 15:23 — forked from jwage/SplClassLoader.php
Add MIT license.
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
@KennFatt
KennFatt / random.php
Created April 14, 2018 10:57
Randomize-ing with PHP
<?php
/**
* Randomize algorithm. In this case, I tried to random those bytes.
* April 14, 2018.
*
* @author KennFatt
*/
$y = ["\xff", "\x00", "\xfe", "\xf3", "\x00"];
$m = [];
$x = $y;