Skip to content

Instantly share code, notes, and snippets.

View bhaidar's full-sized avatar

Bilal Haidar bhaidar

View GitHub Profile
@bhaidar
bhaidar / PieChartSvg.vue
Created January 17, 2023 22:00 — forked from marwinious/PieChartSvg.vue
SVG Pie Chart Component for Vue.js
/*
Initial concept from: https://seesparkbox.com/foundry/how_to_code_an_SVG_pie_chart
Vue.js component by Darius Babcock
*/
<template>
<div class="pie_chart_svg_container">
<svg
:height="diameter"
:width="diameter"
@bhaidar
bhaidar / Response.php
Created December 19, 2022 11:29 — forked from jeffochoa/Response.php
Laravel HTTP status code
<?php
// This can be found in the Symfony\Component\HttpFoundation\Response class
const HTTP_CONTINUE = 100;
const HTTP_SWITCHING_PROTOCOLS = 101;
const HTTP_PROCESSING = 102; // RFC2518
const HTTP_OK = 200;
const HTTP_CREATED = 201;
const HTTP_ACCEPTED = 202;
@bhaidar
bhaidar / download_csv.php
Created August 26, 2022 08:36 — forked from mpijierro/download_csv.php
Example streaming large CSV files with Laravel and thousands of queries
<?php
namespace Src\Csv;
use Illuminate\Http\Response;
use Symfony\Component\HttpFoundation\StreamedResponse;
/**
* Class DownloadLargeCsv
*
@bhaidar
bhaidar / index.php
Created February 16, 2022 08:28 — forked from PovilasKorop/index.php
PHP NumberFormatter Demo
<?php
function getFormattedNumber(
$value,
$locale = 'en_US',
$style = NumberFormatter::DECIMAL,
$precision = 2,
$groupingUsed = true,
$currencyCode = 'USD',
) {
@bhaidar
bhaidar / Composer.php
Created February 8, 2022 12:55 — forked from sam-ngu/Composer.php
Laravel helper class to run composer command programmatically.
<?php
namespace App;
class Composer extends \Illuminate\Support\Composer
{
public function run(array $command)
{
@bhaidar
bhaidar / vue.md
Last active December 18, 2021 18:29 — forked from DawidMyslak/vue.md
Vue.js and Vuex - best practices for managing your state

Vue.js and Vuex - best practices for managing your state

Modifying state object

Example

If you have to extend an existing object with additional property, always prefer Vue.set() over Object.assign() (or spread operator).

Example below explains implications for different implementations.

@bhaidar
bhaidar / pivot-tables.md
Created April 14, 2021 22:14 — forked from Braunson/pivot-tables.md
Laravel 8.x - Diving into Pivot Tables

Laravel 6 - Diving Into Pivot Tables

Pivot tables can be confusing and a little hard to wrap your head around at first. In this quick article we are going to dive into what a pivot table is, how to create one and finally how to use the pivot table. Let's dive in!

What is a pivot table?

A pivot table is used to connect relationships between two tables. Laravel provides a Many To Many relationship where you can use a pivot table.

@bhaidar
bhaidar / useGeolocation.md
Created November 18, 2020 19:53 — forked from whoisryosuke/useGeolocation.md
React Hooks - Geolocation use native browser API

useGeolocation

React sensor hook that tracks user's geographic location.

Hook

const useGeolocation = () => {
  const [state, setState] = useState({
    accuracy: null,
@bhaidar
bhaidar / EslintNodeJS.md
Created August 10, 2020 06:42 — forked from LucasMallmann/EslintNodeJS.md
Eslint and Prettier configuration for NodeJS and Express projects

Eslint and prettier config for nodejs and express projects

Eslint and Libs

You need to install eslint and some other config libs.

yarn add eslint prettier eslint-config-prettier eslint-plugin-prettier -D

yarn eslint --init

.eslintrc.js

function diffArray(arr1, arr2) {
let arr1UniqueItems = arr1.filter(item => arr2.indexOf(item) < 0);
let arr2UniqueItems = arr2.filter(item => arr1.indexOf(item) < 0);
return [...arr1UniqueItems, ...arr2UniqueItems];
}