Skip to content

Instantly share code, notes, and snippets.

View MrNaif2018's full-sized avatar
🎯
Always Improving

MrNaif2018

🎯
Always Improving
View GitHub Profile
@MrNaif2018
MrNaif2018 / docker-compose.yml
Last active April 10, 2022 13:36
BitcartCC minimal BTC with Lightning docker-compose file
version: "3"
services:
admin:
restart: unless-stopped
image: bitcartcc/bitcart-admin:stable
expose:
- "4000"
command: yarn start
environment:
BITCART_ADMIN_LOG_FILE: bitcart.log

Keybase proof

I hereby claim:

  • I am MrNaif2018 on github.
  • I am mrnaif (https://keybase.io/mrnaif) on keybase.
  • I have a public key whose fingerprint is AB22 4F6F 2ED1 1812 47E7 1D83 5CDE 5043 6C3D B40C

To claim this, I am signing this object:

@MrNaif2018
MrNaif2018 / theme.css
Created November 20, 2021 21:08
Sample theme for BitcartCC store
:root {
--brand-color: #162d50;
--primary: var(--brand-color) !important;
--success: var(--brand-color) !important;
--link: var(--brand-color) !important;
}
@MrNaif2018
MrNaif2018 / product.html
Last active March 9, 2024 19:42
BitcartCC Templates example #1: Simple summary table
<tr>
<td style="direction:ltr;font-size:0px;padding:0px;text-align:center;">
<!--[if mso | IE]>
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
<tr>
<td
class="" style="vertical-align:top;width:300px;"
>
@MrNaif2018
MrNaif2018 / index.js
Created December 16, 2019 13:47
Dynamical loading of env variables in nuxt.js
export const state = () => ({
env: {}
})
export const mutations = {
setEnv (state, env) {
state.env = env
}
}
export const routeOption = (route, key, value) => {
return route.matched.some((m) => {
if (process.client) {
// Client
return Object.values(m.components).some(
component => component.options && component.options[key] === value
)
} else {
// SSR
return Object.values(m.components).some(component =>
@MrNaif2018
MrNaif2018 / auth.js
Last active December 13, 2019 18:58
JWT refreshing token plugin with @nuxtjs/auth
const strategy = 'local'
const FALLBACK_INTERVAL = 900 * 1000 * 0.75
async function refreshTokenF ($auth, $axios, token, refreshToken) {
if (token && refreshToken) {
try {
const response = await $axios.post('/refresh_token',
{
'token': refreshToken
}
@MrNaif2018
MrNaif2018 / axios.js
Created December 7, 2019 20:14
Configure axios baseUrl dynamically
export default ({ store, $axios }) => {
$axios.defaults.baseURL = store.state.env.URL
}
@MrNaif2018
MrNaif2018 / nuxt.config.js
Created December 7, 2019 20:05
@nuxtjs/auth configuration for refresh tokens and cookies
axios: {
baseURL: 'http://localhost:8000'
},
router: {
middleware: ['loggedIn']
},
auth: {
localStorage: false,
cookie: {
options: {
@MrNaif2018
MrNaif2018 / login.js
Last active January 19, 2020 19:37
Authentification using @nuxtjs/auth(JWT with refresh tokens)
this.$axios.post('/token', {
email: this.email,
password: this.password
}).then((resp) => {
this.$auth.setToken('local', 'Bearer ' + resp.data.access_token)
this.$auth.setRefreshToken('local', resp.data.refresh_token)
this.$axios.setHeader('Authorization', 'Bearer ' + resp.data.access_token)
this.$auth.ctx.app.$axios.setHeader('Authorization', 'Bearer ' + resp.data.access_token)
this.$axios.get('/users/me').then((resp) => { this.$auth.setUser(resp.data); this.$router.push('/') })
})