Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Jitendra adhocore

🎯
Focusing
View GitHub Profile
View primes.php
<?php
/**
* Alternative prime number generator
*
* Generates first <n> prime numbers using
* the prime numbers themselves
*
* @author Jitendra Adhikari <jiten.adhikary@gmail.com>
*
@adhocore
adhocore / sub.php
Last active Sep 9, 2015
A simple php cli tool to traverse movie directories and download the missing subtitles from subscene.com (suited for movies from yify torrents)
View sub.php
#!/usr/bin/env php
<?php
/*
* A simple php cli tool to traverse movie directories
* and download the missing subtitles from subscene.com
* (Especially suited for movies from yify torrents)
*
* Usage: php sub.php /path/to/movies/
*
@adhocore
adhocore / qwerty.php
Created Dec 13, 2015
map English alphabets to their position in qwerty layout keyboard, and reverse
View qwerty.php
<?php
/*
* QWERTY encode decode
*
* qwerty_encode maps English alphabets to their
* position in qwerty layout keyboard like so:
* a -> q, b -> w, c -> e ... etc
*
* qwerty_decode does the reverse
@adhocore
adhocore / MagentoTranslateCSVGenerator.php
Created Nov 22, 2013
a handy tool that generates CSV data for magento theme translation
View MagentoTranslateCSVGenerator.php
<?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
@adhocore
adhocore / constantAccess.php
Last active Dec 30, 2015 — forked from samundra/constant access.php
dynamic access constant - fork | making more promising and fail-safe
View constantAccess.php
<?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
adhocore / fizzbuzz.php
Created Dec 8, 2013
Fizzbuzz implementation in PHP with minimal codes
View fizzbuzz.php
<?php
// PHP fizzbuzz implementation by Jitendra Adhikari
// see: http://content.codersdojo.org/code-kata-catalogue/fizz-buzz/
//
// 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
adhocore / stringBorder.php
Created Dec 18, 2013
max length of border having atleast three non-overlapping occurance in a string
View stringBorder.php
<?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
adhocore / upload.php
Last active Feb 4, 2017
AJAX file upload with progress bar, as minimal as it can be.
View upload.php
<?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
adhocore / maqebot.php
Last active Oct 8, 2017
Maqe Bot (PHP7). Sample usage: `php maqebot.php W5RW5RW2RW1R`
View maqebot.php
<?php
/**
* The Bot.
*/
class Bot
{
const DIR_NORTH = 0;
const DIR_EAST = 1;
const DIR_SOUTH = 2;
@adhocore
adhocore / git-branch.md
Created May 15, 2019
Get current git branch without using `git` command
View git-branch.md
cat .git/HEAD | cut -c17-9999

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