Skip to content

Instantly share code, notes, and snippets.

View razan-rai's full-sized avatar

Rajan Rai razan-rai

View GitHub Profile
@razan-rai
razan-rai / markdown
Created March 23, 2020 13:18 — forked from joshuapekera/markdown
Markdown Cheat Sheet
This is intended as a quick reference and showcase. For more complete info, see [John Gruber's original spec](http://daringfireball.net/projects/markdown/) and the [Github-flavored Markdown info page](http://github.github.com/github-flavored-markdown/).
This cheatsheet is specifically *Markdown Here's* version of Github-flavored Markdown. This differs slightly in styling and syntax from what Github uses, so what you see below might vary a little from what you get in a *Markdown Here* email, but it should be pretty close.
You can play around with Markdown on our [live demo page](http://www.markdown-here.com/livedemo.html).
##### Table of Contents
[Headers](#headers)
[Emphasis](#emphasis)
[Lists](#lists)
$expenses = DB::table('dispatches')
->select(DB::raw('COUNT(*) as total_dispatch, MONTH(created_at) as month, YEAR(created_at) as year'))
->groupBy(DB::raw('YEAR(created_at) ASC, MONTH(created_at) ASC'))->get();
dd($expenses);
$stats = DB::table('dispatches')
->whereRaw('YEAR(created_at) = ?',2019)
->groupBy('month')
->orderBy('month', 'ASC')
var productType = $(this).data('producttype');
$("select option").each(function(){
if ($(this).text() == productType)
$(this).attr("selected","selected");
});
@razan-rai
razan-rai / gist:676024b6f232ff2e682a6abf184b620c
Created August 29, 2019 12:18
Laravel excel collection import validation and skiping
public function collection(Collection $rows)
{
// Initialize number
$numbers = array();
foreach ($rows as $row)
{
$validator = Validator::make($row->toArray(), [
on store:
$this->validate($request, [
'date' => 'unique:mileages,date,NULL,id,user_id,'.\Auth::id(),
'mileage'=>'required'
'role_id' => 'required|unique:settings,role_id,NULL,id,org_id,' . Auth()->user()->org_id,
]);
On update:
$this->validate($request, [
'date' => 'unique:mileages,date,'. $id .',id,user_id,'.\Auth::id(),
'mileage'=>'required'
@razan-rai
razan-rai / eloquent-cheatsheet.php
Created March 7, 2017 04:08 — forked from hassansin/eloquent-cheatsheet.php
Laravel 5 Eloquent CheatSheet #laravel #eloquent
Model::
/*Select*/
select('col1','col2')
->select(array('col1','col2'))
->select(DB::raw('businesses.*, COUNT(reviews.id) as no_of_ratings, IFNULL(sum(reviews.score),0) as rating'))
->addSelect('col3','col4')
->distinct() // distinct select
/*From*/
//example demonstrate generating short url from full url
public function getShortUrl($long_Url)
{
$apiKey="AIzaSyByZhZ9RVU3v-ImcTcvAOVqYIEvPeQ4V5wff";
$data = array('longUrl' => $long_Url, 'key' => $apiKey);
$jsonData = json_encode($data);
$curlObj = curl_init();
curl_setopt($curlObj, CURLOPT_URL, 'https://www.googleapis.com/urlshortener/v1/url?key='.$apiKey);
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0);
@razan-rai
razan-rai / Cheat Sheet
Last active January 12, 2017 07:27
xpath-cheatsheet
// XPath CheatSheet
// To test XPath in your Chrome Debugger: $x('/html/body')
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/
// 0. XPath Examples.
// More: http://xpath.alephzarro.com/content/cheatsheet.html
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class
// XPath CheatSheet
// To test XPath in your Chrome Debugger: $x('/html/body')
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/
// 0. XPath Examples.
// More: http://xpath.alephzarro.com/content/cheatsheet.html
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class
@razan-rai
razan-rai / gist:c1897e10bca6fa35f3f50852d2caeeb0
Created January 9, 2017 06:46
xpath to get data starts with specific character or string
//edtracting Telephone no and other stuff
<div class="inhalt-links">
<h2>
Deutsche Verkehrswacht
<br>
Verkehrswacht Dortmund e. V.
<br>
</h2>
<h3>
Standnummer:&nbsp;