Skip to content

Instantly share code, notes, and snippets.

View omitobi's full-sized avatar
👑
The faithful shall receive the crown of life from Jesus

Oluwatobi Samuel Omisakin omitobi

👑
The faithful shall receive the crown of life from Jesus
View GitHub Profile
@omitobi
omitobi / gist:c51da78f7b591a22fcfba849077754de
Created January 3, 2024 13:10
Jetbrains Use cheatsheet
1. Search words matching
a. set[\s\S]*?Attribute - Searches for setHelloAttribute, setHiAttribute, etc any words starting with 'set' and 'Attributes'
@omitobi
omitobi / custom_logs_handler.php
Created July 14, 2023 06:49
Custom Laravel Logs Handler
<?php
declare(strict_types=1);
namespace App\ExampleDirectory\Loggers;
use Monolog\Handler\HandlerInterface;
use Monolog\Logger as MonologLogger;
use Illuminate\Log\Logger;
use Psr\Log\LoggerInterface;
@omitobi
omitobi / pre-commit-eslint
Created March 9, 2022 19:21 — forked from linhmtran168/pre-commit-eslint
Pre-commit hook to check for Javascript using ESLint
#!/bin/sh
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$")
if [[ "$STAGED_FILES" = "" ]]; then
exit 0
fi
PASS=true
@omitobi
omitobi / connect.js
Created November 12, 2021 14:49
connect to mongo once
await mongoose.connect(dbUrl, {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
useFindAndModify: false,
});
const connection = mongoose.connection;
connection.once("open", function() {
@omitobi
omitobi / ts-boilerplate.md
Created August 6, 2021 09:03 — forked from silver-xu/ts-boilerplate.md
Setup a Node.js project with Typescript, ESLint, Prettier, Husky

Setup a Node.js project with Typescript, ESLint, Prettier, Husky

1_D8Wwwce8wS3auLAiM3BQKA

Starting a personal node project could be easy; starting a team node project could be challenging.

I am a developer currently working in SEEK Australia.

In my experience, common mistakes developer make when starting a projects are:

  • No Linting
@omitobi
omitobi / replicate.php
Last active July 29, 2020 13:22
Replicate a value
<?php
/**
* Replicate a value
*
* @param $value
* @param int $times - ps: modify it to handle values less than 2
* @param bool $handleClosure
* @return array
*/
function getSolinorUrl()
{
$json = '{
"sph-account": "test",
"sph-cancel-url": "http://example.test/api/cards/cancel",
"sph-failure-url": "http://example.test/api/cards/failure",
"sph-merchant": "test_merchantId",
"sph-request-id": "6saduyd7-648f-43ee-a65c-8sdaskd8wq",
"sph-success-url": "http://example.test/api/cards/success?for=5",
"sph-timestamp": "2019-04-02T12:31:19Z",
@omitobi
omitobi / helpers.php
Created February 13, 2019 11:58 — forked from molayli/helpers.php
Laravel redirect without return statment
<?php
//.....
if(!function_exists('freeRedirect')){
function freeRedirect($to = '/'){
throw new \Illuminate\Http\Exception\HttpResponseException(redirect($to));
}
@omitobi
omitobi / image_upload.html
Created November 2, 2018 09:12
Upload Image with VueJS
<!-- See: https://jsfiddle.net/edwinencomienda/eywraw8t/444118/ -->
<div id="app">
<form @submit.prevent="onSubmit">
<input type="file" @change="onFileChange">
<button>Submit</button>
</form>
</div>
<script>
new Vue({
@omitobi
omitobi / maintain_query_result_order
Created August 30, 2018 05:49
maintain the order of queried records
$users_ids = [1,3,2];
$items = collect($users_ids);
$fields = $items->map(function ($ids){
return '?';
})->implode(',');
$ordered = User::orderbyRaw("FIELD (id, ".$fields.")", $items->prepend('id'))
->find($users_ids)->pluck('id');