Skip to content

Instantly share code, notes, and snippets.

View alimranahmed's full-sized avatar

Al Imran Ahmed alimranahmed

View GitHub Profile
@alimranahmed
alimranahmed / Queue.php
Last active October 15, 2019 06:20
Queue - Data Structure using PHP
<?php
/**
* Implementation of Queue using PHP
* @author Al- Imran Ahmed
*/
class Element{
public $value;
public $next;
}
@alimranahmed
alimranahmed / uk_mobile_regex.md
Last active September 6, 2019 06:22
UK Mobile Number Validation Regex

((0|44|\+44|\+44\s*\(0\)|\+44\s*0)\s*)?7(\s*[0-9]){9}

@alimranahmed
alimranahmed / extendCollectionWithPaginate.php
Last active January 31, 2019 15:18
Extends Laravel collection with paginate() function like Eloquent
<?php
//----------------------------------------How to use?----------------------------------------------
// 1. Add the following private method in App\Providers\AppServiceProvider class
// 2. Call this function from boot() method of same class: $this->extendCollectionWithPaginate();
//-------------------------------------------------------------------------------------------------
/**
* Macro to extends Laravel Collection
* If you have a collection called $item and you want to paginate it like Eloquent paginate:
* $items->paginate($perPage)
@alimranahmed
alimranahmed / laravel.js
Created July 5, 2018 17:33 — forked from JeffreyWay/laravel.js
Want to send a DELETE request when outside of a form? This will handle the form-creation bits for you dynamically, similar to the Rails implementation. (Requires jQuery, but doesn't have to.) To use, import script, and create a link with the `data-method="DELETE"` attribute.
/*
<a href="posts/2" data-method="delete"> <---- We want to send an HTTP DELETE request
- Or, request confirmation in the process -
<a href="posts/2" data-method="delete" data-confirm="Are you sure?">
*/
(function() {
@alimranahmed
alimranahmed / xml-decoder.py
Last active October 29, 2017 02:15
A very simple tool to decode xml. Python's Tkinter library used to build the interface. Python3^ is required.
import html
from tkinter import *
import xml.dom.minidom as dom
# author Al Imran Ahmed
# A very simple interface to decoded xml. i.e. &lttag&gt => <tag>
# requires python3^ with tkinter GUI library installed
class Application(Frame):
def decode_xml(self):
@alimranahmed
alimranahmed / .vimrc
Last active March 14, 2017 07:52
Minimal .vimrc for programmer without any plugin
"Change the leader key from \\ to comma
let mapleader = ','
"Show line number of row
set number
"Write automatically when close the buffer
set autowriteall
"Limit the Text window with 80 character
@alimranahmed
alimranahmed / insertionSort.c
Created February 10, 2016 11:11
Implementation of insertion sort algorithm using C
/**
* Created by Al- Imran Ahmed
* Sorting an array using insertion sort algorithm
* @param int a[] is an array to be sorted
* @param int size is the size of the array
*/
void insertionSort(int a[], int size){
for(int i = 1; i < size; i++){
for(int j = i; j >= 0; j--){
@alimranahmed
alimranahmed / Stack.php
Last active January 19, 2016 13:18
Stack - Data Structure using PHP
<?php
/**
* Implementation of Stack using PHP
* @author Al- Imran Ahmed
*/
class Node{
public $value;
public $next;
}
Problem Statement
-----------------------------
Find an Array:
Implement a method that given two arrays as parameters will find the starting index where the second parameter occurs as a sub-array in the array given as the first parameter.
Your implementations should return -1 if the sub-array cannot be found.
Your implementation must implement the FindArray interface given bellow: