Skip to content

Instantly share code, notes, and snippets.

View bantya's full-sized avatar
🎯
Focussing

Rahul Thakare bantya

🎯
Focussing
  • http://127.0.0.1:4200
  • http://127.0.0.1:8080
  • 12:41 (UTC +05:30)
  • X @rkkth
View GitHub Profile
@bantya
bantya / mb_substr_replace.php
Created January 24, 2017 07:40 — forked from stemar/mb_substr_replace.php
Multibyte substr_replace(). The mbstring library doesn’t come with a multibyte equivalent of substr_replace(). This function behaves exactly like substr_replace() even when the arguments are arrays.
<?php
function mb_substr_replace($string, $replacement, $start, $length=NULL) {
if (is_array($string)) {
$num = count($string);
// $replacement
$replacement = is_array($replacement) ? array_slice($replacement, 0, $num) : array_pad(array($replacement), $num, $replacement);
// $start
if (is_array($start)) {
$start = array_slice($start, 0, $num);
foreach ($start as $key => $value)
@bantya
bantya / debug.css
Created April 28, 2017 19:13 — forked from donatj/debug.css
Pure CSS Debuggery
*[class]:before {
position: absolute;
background: rgba(10,10,10,.6);
padding: 10px;
border-radius: 4px;
color: white;
font-size: 10px;
display: block;
content: "[" attr(class) "] " ;
}
@bantya
bantya / ColorCLI.php
Created April 28, 2017 19:16 — forked from donatj/ColorCLI.php
Simple CLI color class
<?php
class ColorCLI {
static $foreground_colors = array(
'bold' => '1', 'dim' => '2',
'black' => '0;30', 'dark_gray' => '1;30',
'blue' => '0;34', 'light_blue' => '1;34',
'green' => '0;32', 'light_green' => '1;32',
'cyan' => '0;36', 'light_cyan' => '1;36',
@bantya
bantya / queries.sql
Created June 18, 2017 06:44 — forked from alsma/queries.sql
Many-to-many interview question
-- select all query --
SELECT b.bookTitle, a.authorName FROM book b
INNER JOIN author_book ab ON ab.bookID = b.bookID
INNER JOIN author a ON a.authorID = ab.authorID
ORDER BY b.bookTitle
-- select all with authors concantenated --
SELECT b.bookTitle, GROUP_CONCAT(a.authorName) authors FROM book b
<?php namespace Octopus;
use \Closure;
class MiddlewareComposer
{
protected $pipe;
protected $context;
protected $errorHandler;
protected $successHandler;
@bantya
bantya / Inflect.php
Created September 19, 2017 19:26 — forked from tbrianjones/Inflect.php
A PHP Class for converting English words between Singular and Plural.
<?php
// original source: http://kuwamoto.org/2007/12/17/improved-pluralizing-in-php-actionscript-and-ror/
/*
The MIT License (MIT)
Copyright (c) 2015
Permission is hereby granted, free of charge, to any person obtaining a copy
@bantya
bantya / OpenWithSublimeText3.bat
Created January 23, 2018 07:00 — forked from roundand/OpenWithSublimeText3.bat
Open folders and files with Sublime Text 3 from windows explorer context menu (tested in Windows 7)
@echo off
SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@bantya
bantya / Sublime Text 3 Scopes
Created April 4, 2018 17:29 — forked from danpe/Sublime Text 3 Scopes
Sublime Text 3 scopes to be used for Snippets Makers / Plugin Developers.
A list of Sublime Text 3 scopes to be used for Snippets Makers / Plugin Developers.
Main Symbol Scopes: entity.name.function, entity.name.type, meta.toc-list
ActionScript: source.actionscript.2
AppleScript: source.applescript
ASP: source.asp
Batch FIle: source.dosbatch
BibTex: source.bibtex
C#: source.cs
@bantya
bantya / hexdump.php
Created May 16, 2018 04:25 — forked from Norcoen/hexdump.php
Dump PHP String as HEX
<?php
/* Found at http://stackoverflow.com/questions/1057572/how-can-i-get-a-hex-dump-of-a-string-in-php */
function hex_dump($data, $newline="\n")
{
static $from = '';
static $to = '';
static $width = 16; # number of bytes per line
@bantya
bantya / README.md
Created May 30, 2018 14:10 — forked from Ocramius/README.md
`__invoke` vs `function` vs `Closure`