Skip to content

Instantly share code, notes, and snippets.

View waptik's full-sized avatar
💻
Learning JavaScript and ReactJS...

Stephane Mensah waptik

💻
Learning JavaScript and ReactJS...
View GitHub Profile
@waptik
waptik / compress-base64-imgs.js
Created June 16, 2024 18:48 — forked from 1isten/compress-base64-imgs.js
js compress image (base64) using canvas api
const toBase64 = (file) => new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = (e) => resolve(e.target.result);
reader.onerror = (err) => reject(err);
});
const compressBase64 = (src, quality = 0.5) => new Promise((resolve) => {
const img = new Image();
img.src = src;
@waptik
waptik / ngrok_hostname.sh
Created January 21, 2024 22:00 — forked from rjz/ngrok_hostname.sh
Get ngrok hostname from command line
#!/bin/sh
# ngrok's web interface is HTML, but configuration is bootstrapped as a JSON
# string. We can hack out the forwarded hostname by extracting the next
# `*.ngrok.io` string from the JSON
#
# Brittle as all get out--YMMV. If you're still reading, usage is:
#
# $ ./ngrok_hostname.sh <proto> <addr>
#
openapi: 3.0.0
info:
description: "This is a sample server Petstore server. You can find out more about
Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net,
#swagger](http://swagger.io/irc/). For this sample, you can use the api key
`special-key` to test the authorization filters."
version: 1.0.2
title: Swagger Petstore
termsOfService: http://swagger.io/terms/
contact:
@waptik
waptik / fauna-adapter.js
Last active December 31, 2020 17:18 — forked from s-kris/fauna-adapter.js
faunadb adapter for next-auth for next.js
/**
* This is a faunadb adapter for next-auth
* original source: https://gist.github.com/s-kris/fbb9e5d7ba5e9bb3a5f7bd11f3c42b96
* create collections and indexes in your faunadb shell(dashboard or cli) using the following queries:
CreateCollection({name: 'accounts'});
CreateCollection({name: 'sessions'});
CreateCollection({name: 'users'});
CreateCollection({name: 'verification_requests'});
@waptik
waptik / JsonMiddleware.php
Created July 23, 2018 01:24 — forked from meSingh/JsonMiddleware.php
If you are using laravel as api only, you might want to return JSON on every request, even on errors/exceptions. The easiest way to do so is using this middleware globally.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class JsonMiddleware
{
public function handle(Request $request, Closure $next)