Skip to content

Instantly share code, notes, and snippets.

View guillaumeduhan's full-sized avatar
💭
Next & Supabase!

Guillaume Duhan guillaumeduhan

💭
Next & Supabase!
View GitHub Profile
-- 1. create the function
CREATE OR REPLACE FUNCTION log_post_update()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = NOW();
IF NEW.title <> OLD.title THEN
INSERT INTO posts_logs (post_id, log_message)
VALUES (NEW.id, 'Updated title');
ELSEIF NEW.description <> OLD.description THEN
@guillaumeduhan
guillaumeduhan / ncom.js
Created December 7, 2023 13:27
Generate a .TSX file [snippet vscode]
"ncomp": {
"scope": "javascriptreact,typescriptreact,tsx",
"prefix": "ncomp",
"body": [
"'use client';",
"export default function $TM_FILENAME_BASE() {",
"return <div>New component with filename</div>;",
"}"
]
},
const fs = require('fs');
let rawdata = fs.readFileSync('sheets1.json');
let raw1 = JSON.parse(rawdata)
let rawdata2 = fs.readFileSync('sheets2.json');
let raw2 = JSON.parse(rawdata2)
// let data = JSON.stringify(raw1.filter(x => x !== null));
// fs.writeFileSync('sheets1.json', data);
@guillaumeduhan
guillaumeduhan / Form.vue
Created December 7, 2022 10:46
Marc Form.vue
<script setup>
import { reactive } from "vue";
import { defineEmits } from "vue";
import { useApi } from '@/composables/useApi'
const { coucou } = useApi();
const emit = defineEmits(["recupereLeForm"]);
const props = defineProps({
{
id: { type: String, unique: true, required: true },
domain: Array,
subdomain: { type: String },
file_external_id: Array,
contract_external_id: Array,
visualFileName: { type: String, default: "document.pdf" }, // n'a pas lieu d'être, nom + type généré à la volée
name: { type: String, required: true },
code: { type: String, default: "" }, // internal unique name for file upload ????
desc: { type: String },
@guillaumeduhan
guillaumeduhan / payment.js
Created March 11, 2022 11:47
Stripe get payment intent
async getPaymentIntent () { // get the payment intent from API
const data = {
amount: this.formatStripePrice(this.getCurrentCoaching.price),
currency: 'eur'
}
this.isLoading = true
await this.$api.payment.getPaymentIntent(data, process.env.NODE_ENV) // call API, env is to switch dev/staging/prod
.then(({ client_secret }) => {
this.clientSecret = client_secret
this.buildCard() // build front module payment
@guillaumeduhan
guillaumeduhan / app.js
Created March 10, 2022 14:11
Stripe API create-payment-intent
require("dotenv").config()
const express = require('express')
const app = express()
const cors = require('cors')
const bodyParser = require('body-parser')
const PORT = process.env.PORT || 4000
app.use(cors());
app.use(express.json());
app.use(bodyParser.json(), cors())
@guillaumeduhan
guillaumeduhan / App.vue
Created June 17, 2021 17:28
Vue 3: props
<template>
<div>
<p>{{ msg }}</p>
</div>
</template>
<script>
import { reactive, toRefs } from "vue";
export default {
@guillaumeduhan
guillaumeduhan / App.vue
Created June 17, 2021 17:15
Vue 3: watch
<template>
<div>
<input v-model="name" />
<p>{{ msg }}</p>
</div>
</template>
<script>
import { reactive, toRefs, computed, watch } from "vue";
@guillaumeduhan
guillaumeduhan / App.vue
Created June 17, 2021 17:07
Vue 3: computed
<template>
<div>
<input v-model.lazy="name" />
<p>{{ msg }}</p>
</div>
</template>
<script>
import { reactive, toRefs, computed } from "vue";