Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
# Function to display usage instructions
usage() {
echo "Usage: $0 <db_name> <db_user> <db_password>"
exit 1
}
// vi /etc/systemd/system/foo.service
[Unit]
Description=Run a command at startup
[Service]
ExecStart=/path/to/your/command
[Install]
WantedBy=multi-user.target
// select the main firebase project
firebase use <main-project-id>
// list projects
firebase projects:list
// firebase target:apply hosting <app-id> <site-url>
firebase target:apply hosting enjaz-web enjaz.bedayat.ly
// firebase deploy --only hosting:<app-id>
@moaoa
moaoa / save-token-after-login-postman.js
Last active September 10, 2024 18:31
save the token after login in postman
//json() is your backend response
pm.collectionVariables.set('token', pm.response.json().token)
import jsPdf from 'jspdf';
domToPng(ticketElement).then(dataUrl => {
const pdf = new jsPdf();
const imgProps = pdf.getImageProperties(dataUrl);
const pdfWidth = pdf.internal.pageSize.getWidth();
// const pdfHeight = pdf.internal.pageSize.getHeight();
@moaoa
moaoa / postman_add_token_to_requests.js
Created January 22, 2024 13:26
add token on every request in postman
const token = pm.environment.get("variable_key");
pm.request.headers.add('Authorization', token)
@moaoa
moaoa / defineEmits.js
Created January 1, 2024 09:27
to type the defineEmits hook in vue
const emit = defineEmits<{
(event: "faqDeleted", data: Faq);
(event: "close", data: any);
}>();
@moaoa
moaoa / moment_format_date.js
Created September 25, 2023 21:08
date formating in moment
import moment from "moment";
const formatDate = (date) => {
const momntDate = moment(date);
if (!momntDate.isValid()) "";
return moment(date).format("D-MM-YYYY");
};
axios.get('/api/some-endpoint')
.then(response => {
// Handle successful response
console.log(response.data);
})
.catch(error => {
// Handle error
if (error.response) {
// The request was made, and the server responded with a status code
// that falls out of the range of 2xx
@moaoa
moaoa / vuex_presist.js
Created September 16, 2023 16:21
presist vuex store in local storage
const vuexLocalStorage = new VuexPersist({
key: 'sano-vuex',
storage: window.localStorage, // or window.sessionStorage or localForage
// pass the state of the store to be persisted
reducer: state => ({
auth: state.auth,
lang: state.lang,
}),
});