Skip to content

Instantly share code, notes, and snippets.

View mkdesignn's full-sized avatar

mohammad mkdesignn

View GitHub Profile
@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="([^"]+)"/';
@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 / 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 / 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 / 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 / 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
server {
listen 185.13.231.188:500;
root /home/ftp_users/ftp/demo_core/public;
index index.php index.html index.htm;
server_name test.com;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
#!/bin/bash
# Basic configuration: datestamp e.g. YYYYMMDD
DATE=$(date +"%Y%m%d")
# Location of your backups (create the directory first!)
BACKUP_DIR="/home/backup/database"
function getBranch($belief_id){
$con = DBINT::DBCon();
$qry = "SELECT branch.idbranch, branch.branchname from worldviews inner join branch on branch.idbranch = worldviews.branchid where beliefid = ".$belief_id.' group by branchid';
$stmt = $con->prepare($qry);
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
$r = $stmt->fetchAll();
$con = null;
@mkdesignn
mkdesignn / gist:7a80a17a695f1eab761ad0777e07862d
Created May 17, 2019 09:32
Send notification in laravel
$this->notificationService($device->device_token, $notification['target_screen'], $message['body'], $message['title']);
function notificationService($token, $targetScreen, $body = "", $title = "")
{
$optionBuilder = new OptionsBuilder();
$optionBuilder->setTimeToLive(60 * 20);
$optionBuilder->setCollapseKey('type_a');
$optionBuilder->setContentAvailable(true);
try {
$optionBuilder->setPriority(OptionsPriorities::high);