Skip to content

Instantly share code, notes, and snippets.

View HakamRaza's full-sized avatar
🚀
To the Mars !

HakamRaza HakamRaza

🚀
To the Mars !
View GitHub Profile
@HakamRaza
HakamRaza / ReusableModal.tsx
Last active March 12, 2022 14:27
Reusable Modal with Pagination - Recommended For Tutorials
import React from "react";
import {
SafeAreaView,
ScrollView,
Text,
StyleSheet,
View,
Image,
Modal,
ImageSourcePropType,
@HakamRaza
HakamRaza / openMapApp.tsx
Created July 6, 2021 07:28
RN - Open map Option
import { Linking, Platform } from 'react-native';
function _openMapLocationByAddress(){
const url = Platform.select({
ios: `maps:0,0?q=${address_string}`,
android: `geo:0,0?q=${address_string}`,
})
Linking.openURL(url as string)
}
@HakamRaza
HakamRaza / Merchant.php
Created January 21, 2022 04:07
Implementing Scope inside Laravel
<?php
namespace App\Model;
class Merchant extends Model
{
//...
/**
* scope "productAvailable()" that can be use for Merchant instance
@HakamRaza
HakamRaza / AnotherController.php
Created January 21, 2022 04:18
Using Traits inside Laravel Controller
<?php
use App\Http\Traits\StudentTrait;
class AnotherController extends Controller
{
use StudentTrait;
/**
@HakamRaza
HakamRaza / AbsenceCalendarController.php
Created January 21, 2022 04:24
Using Trait inside Models
<?php
namespace App\Controller\AbsenceCalendarController;
class EmployeeAbsenceCalendar extends Controller
{
protected $employee;
public function __construct(User $employee)
@HakamRaza
HakamRaza / filetypeValidator.js
Created January 27, 2022 06:30
JS - Validating file types
const fileExtArr = ["png", "jpeg", "tft", "bmp", "jpg"];
const maxFileSize = 4194587;
function validateUploadedFile(elementId) {
let fileElement = getElement(elementId);
const ext = fileUploadJson.docType || "";
if (ext == "" || fileExtArr.indexOf(ext.toLowerCase()) < 0)
{
@HakamRaza
HakamRaza / FuzzySort.js
Created January 27, 2022 08:41
Search Text using Fuzzy Sort
/*
WHAT: SublimeText-like Fuzzy Search
USAGE:
fuzzysort.single('fs', 'Fuzzy Search') // {score: -16}
fuzzysort.single('test', 'test') // {score: 0}
fuzzysort.single('doesnt exist', 'target') // null
fuzzysort.go('mr', ['Monitor.cpp', 'MeshRenderer.cpp'])
// [{score: -18, target: "MeshRenderer.cpp"}, {score: -6009, target: "Monitor.cpp"}]
:: This is to .cbz archive 2 level deep folder containing images using WinRar CLI
:: Resulted Rar archieve then will be change format from .rar to .cbz
:: Archieved directory is removed by -dr flag
:: "C:\Program Files\WinRAR\RaR" is the installed WinRar Rar.exe directory
:: Use - Place this file at selected directory and run script.
FOR /d %%x IN (*.*) DO (
cd "%%x" && (
FOR /d %%y IN (*.*) DO (
@HakamRaza
HakamRaza / Readme.md
Last active May 11, 2022 06:53
ReadMe Add-Ons
@HakamRaza
HakamRaza / 1. Initial Server Setup
Last active October 17, 2022 01:34
Basic - LEMP Stack Setup (ec2, php 8.1, Laravel 9)
/*
* Download .pem, connect SSH tunnel after set up Ubuntu instance.
* Open terminal and use following command
* This setup should more or less the same for any provider like DigitalOcean too.
*/
$ ssh -i "your_pem.pem" ubuntu@<your public dns>.compute.amazonaws.com
/*
* the following command may need root privilage