Skip to content

Instantly share code, notes, and snippets.

View Fanreza's full-sized avatar
🤩
Excited

Muhamad Jamil Fanreza

🤩
Excited
View GitHub Profile
@Fanreza
Fanreza / elixir.txt
Last active February 19, 2024 13:09
Command list run node Elixir Finance
## Install Docker for Ubuntu 22.04
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
@Fanreza
Fanreza / Dockerfile
Created February 8, 2024 11:47
Nuxt dockerfile with multi stage build and distorless image for less bundle size
# Use a large Node.js base image to build the application and name it "build"
FROM node:18-alpine as build
WORKDIR /app
# Copy the package.json and package-lock.json files into the working directory before copying the rest of the files
# This will cache the dependencies and speed up subsequent builds if the dependencies don't change
COPY package*.json /app
# You might want to use yarn or pnpm instead
@Fanreza
Fanreza / useHttp.ts
Created August 17, 2023 11:38
Nuxt composable useFetch with global options and interceptors
import { useFetch } from "#app";
type useFetchType = typeof useFetch;
export const useHttp: useFetchType = (path, options = {}) => {
const config = useRuntimeConfig();
options.baseURL = config.public.baseUrl;
options.onResponseError = (error) => {};
@Fanreza
Fanreza / useRawHttp.ts
Created August 8, 2023 06:36
Nuxt composable $fetch with global options and interceptor
import { useRuntimeConfig } from "nuxt/app";
import { $fetch, FetchOptions } from "ofetch";
export const useRawHttp = async (req: string, options: FetchOptions = {}) => {
const config = useRuntimeConfig();
options.baseURL = config.public.baseUrl; // set your base url on runtime config
options.onResponse = ({ request, response, options }) => {};
@Fanreza
Fanreza / main.dart
Created October 4, 2022 02:39
Disable Orientation Change in Flutter
import 'package:flutter/services.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
.then((_) {
runApp(const MyApp());
});
}
@Fanreza
Fanreza / vite.config.js
Created September 30, 2022 01:30
Use .env in vite config file
import { fileURLToPath, URL } from "url";
import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
export default ({ mode }) => {
process.env = Object.assign(process.env, loadEnv(mode, process.cwd(), ""));
return defineConfig({
plugins: [vue()],
base: process.env.VITE_BASE_DIRECTORY, // can be used now
@Fanreza
Fanreza / .htaccess
Created September 30, 2022 01:28
Htacces for deploying vue apps in subdirectory
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subDirectory
RewriteRule ^subDirectory/index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
@Fanreza
Fanreza / style.css
Last active September 30, 2022 01:31
Override tailwind reset ( when using WYSIWYG tool )
/* Tailwind Override */
h1 {
display: block;
font-size: 2em;
margin-top: 0.67em;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
}
@Fanreza
Fanreza / script.js
Last active June 19, 2022 12:59
HackerRank FizzBuzz
function fizzBuzz(index){
let i = 1
while(i <= index){
if(i% 3 === 0 && i% 5 === 0){
console.log("FizzBuzz")
}
else if (i% 3 === 0) {
console.log("Fizz")
}
@Fanreza
Fanreza / script.js
Created June 19, 2022 12:05
HackerRank WeekDay Text
function weekdaysText(weekdays) {
function getText(arr){
if(arr > weekdays.length || arr < 0){
throw new Error("Invalid weekday number")
} else{
return weekdays[arr]
}
}
return getText
}