Skip to content

Instantly share code, notes, and snippets.

View mkdesignn's full-sized avatar

mohammad mkdesignn

View GitHub Profile
@mkdesignn
mkdesignn / TranslateToWords
Created October 26, 2017 10:04
TranslateToWords
function translateToWords($number)
{
/*****
* A recursive function to turn digits into words
* Numbers must be integers from -999,999,999,999 to 999,999,999,999 inclussive.
*
* (C) 2010 Peter Ajtai
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@mkdesignn
mkdesignn / iterate over all multidimensional array
Created September 19, 2017 08:50
iterate over all multidimensional array
function in_array_r($needle, $haystack, $strict = false) {
// iterate over all items
foreach ($haystack as $key => $item) {
// check if the item is array, if so then call recursive function
if (is_array($item)){
$ret = in_array_r($needle, $item, $strict);
if( is_array($ret) )
return $ret;
@mkdesignn
mkdesignn / vue-elixiri.git
Last active July 30, 2017 04:48
vue and elixir
package.json{
{
"devDependencies": {
"gulp": "^3.8.8",
"laravel-elixir": "^6.0.0-15",
"laravel-elixir-vueify": "^1.0.0",
"laravel-elixir-webpack-official": "^1.0.10"
},
"browser": {
"vue": "vue/dist/vue.common.js"
@mkdesignn
mkdesignn / pdf
Created July 8, 2017 18:56
pdf creator
"niklasravnsborg/laravel-pdf": "^1.5"
$response = view("print.letter", compact("products", "date", "attachment_files", "letter_number", "content"))->render();
$pdf = new Pdf($response,
['format' => 'A4','custom_font_path' => base_path('public'), // don't forget the trailing slash!
'custom_font_data' => [
'IRANSans' => [
'R' => 'IRANSans-Bold-web.ttf', // regular font
'B' => 'IRANSans-Bold-web.ttf', // optional: bold font
'I' => 'IRANSans-Bold-web.ttf', // optional: italic font
@mkdesignn
mkdesignn / CreateCaseTest.php
Created March 28, 2017 15:33
Register new complaint
<?php
use App\Acme\Box;
use App\Cases;
use App\Complaint;
use App\User;
use App\UserMeta;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
@mkdesignn
mkdesignn / SearchResult.php
Created March 25, 2017 15:06
Retrieve Search result from google
function getSearchResult($keyword){
$subject = file_get_contents("http://www.google.com/search?q=".urlencode($keyword));
$href_pattern = '/<h3 class="r">(.*?)<\/h3>/s';
preg_match_all($href_pattern, $subject, $matches);
foreach ($matches[0] as $key => $match) {
$replacment_pattern = '/href="([^"]+)"/';