Skip to content

Instantly share code, notes, and snippets.

View adhocore's full-sized avatar

Jitendra Adhikari adhocore

View GitHub Profile
adhocore / Obfuscator.php
Created December 31, 2013 16:06
Obfuscator - The naive and trivial PHP Code obfuscator | deobfuscator
View Obfuscator.php
* Obfuscator - The naive and trivial PHP Code obfuscator | deobfuscator
* generate() Generates a obfuscated string of given code
* also gives the chunk value required by work()
* work() Reverses the obfuscated string using chunk value given by generate()
* to original code and then execute the code and returns response
adhocore / str_ireplace_array.php
Last active May 7, 2020 20:10
A str_replace_array for PHP
View str_ireplace_array.php
* A str_ireplace_array for PHP
* Case insensitive version of str_replace_array
* See
* @author Jitendra Adhikari | adhocore <>
adhocore / expand_array.php
Last active December 19, 2019 04:05
A helper function expand_array for PHP
View expand_array.php
* A helper function expand_array for PHP
* This is actually developed during the real need to develop JSON api
* I wanted to have JSON api response spitted properly expanded (with semantic nodes)
* But didnot want to do it by playing with arrays (looping, merging n' what not) time and again.
* So, After fetching single dimensional array data from database, with keys having
* some specific delimeter, this helper would do for me what i want to.
adhocore /
Created May 15, 2019 04:20
Get current git branch without using `git` command
cat .git/HEAD | cut -c17-9999

Useful if you are in docker and dont want to install git in your container :)

adhocore / maqebot.php
Last active October 8, 2017 11:22
Maqe Bot (PHP7). Sample usage: `php maqebot.php W5RW5RW2RW1R`
View maqebot.php
* The Bot.
class Bot
const DIR_NORTH = 0;
const DIR_EAST = 1;
const DIR_SOUTH = 2;
adhocore / upload.php
Last active February 4, 2017 10:29
AJAX file upload with progress bar, as minimal as it can be.
View upload.php
* AJAX file upload with progress bar, as minimal as it can be.
* If it doesnot work try latest version of web browser.
// big file upload
ini_set('memory_limit', '1G');
adhocore / stringBorder.php
Created December 18, 2013 15:33
max length of border having atleast three non-overlapping occurance in a string
View stringBorder.php
* For a given string S, a substring b is said to be its border if S starts and end with b.
* Suppose we need length of longest border b that also occurs in S, even after b is trimmed at ends of S.
* This function is aimed at that need. ;)
function maxBorderLen($S){
adhocore / fizzbuzz.php
Created December 8, 2013 16:27
Fizzbuzz implementation in PHP with minimal codes
View fizzbuzz.php
// PHP fizzbuzz implementation by Jitendra Adhikari
// see:
// if you have shorter/smarter ways out, please fork or comment...
echo implode('<br/>', array_map(function($d){
return ($d%15==0)?'fizzbuzz':($d%5==0?'buzz':($d%3==0?'fizz':$d));
}, range(1,100)));
adhocore / constantAccess.php
Last active December 30, 2015 06:09 — forked from samundra/constant access.php
dynamic access constant - fork | making more promising and fail-safe
View constantAccess.php
/* fork: making more promising and fail-safe */
class RegionVO {
const NSW = 35;
const ACT = 37;
const VIC = 38;
const QLD = 9;
const SA = 36;
adhocore / MagentoTranslateCSVGenerator.php
Created November 22, 2013 13:29
a handy tool that generates CSV data for magento theme translation
View MagentoTranslateCSVGenerator.php
* Generates data with ready-to-edit CSV for magento translation
* A handy tool that generates CSV data for magento theme translation
* You can set the $mode to:
* a) either write that data to translate.csv at path you specify,
* b) or just to dump that data in browser for you to copy and use (default).
* In the write mode it appends new data to translate.csv thus you dont