Skip to content

Instantly share code, notes, and snippets.

View gahabeen's full-sized avatar

Gabin Desserprit gahabeen

View GitHub Profile
@gahabeen
gahabeen / migrate.sh
Created July 14, 2024 08:28 — forked from Geczy/migrate.sh
Migrate Coolify to a new server
#!/bin/bash
# This script will backup your Coolify instance and move everything to a new server. Docker volumes, Coolify database, and ssh keys
# 1. Script must run on the source server
# 2. Have all the containers running that you want to migrate
# Configuration - Modify as needed
sshKeyPath="$HOME/.ssh/your_private_key" # Key to destination server
destinationHost="server.example.com"
@gahabeen
gahabeen / 0__readme.txt
Last active March 13, 2021 14:45
NapBots - Dynamic Allocations v1
For updates, leave a comment below!
@gahabeen
gahabeen / 8base-with-Auth0-Passwordless.txt
Last active January 21, 2021 05:30
8base / Auth0 - Passwordless Login/Signup
# 8base / Auth0 - Passwordless Login/Signup
Follow the conversation over there: [https://community.8base.com/t/using-auth0-passwordless-email-connection/529/6](https://community.8base.com/t/using-auth0-passwordless-email-connection/529/6)
@gahabeen
gahabeen / EventBus.js
Created June 29, 2020 20:16
EventBus - Vanilla JS
class EventBus {
registry = new Map()
constructor() {}
on(type, handler) {
const handlers = this.registry.get(type)
const added = handlers && handlers.push(handler)
if (!added) {
this.registry.set(type, [handler])
}
@gahabeen
gahabeen / FormulateForm.js
Last active September 17, 2020 04:56
Extended FormulateSchema/FormulateForm Component as Plugin - for the amazing VueFormulate lib
import FormulateForm from './FormulateForm.vue'
export function plugin(instance) {
instance.extend({
components: {
FormulateForm,
},
})
}
@gahabeen
gahabeen / ducky keyboard remapping.md
Last active January 7, 2023 18:58
AutoHotKeys Remapping Arrows for Ducky One 2 Mini (DKON2061ST)

AutoHotKeys Remapping Arrows for Ducky One 2 Mini (DKON2061ST)

  • Press Fn + Alt + k for 5 seconds.
  • Set up the keys on the right of your space bar as: AltGr > Windows > Ctrl > Fn
  • Press Escape to quit
@gahabeen
gahabeen / TypeOf.ts
Last active May 1, 2020 08:17
Example of a TypeOf FQL method based on composition with Let(<array>)
import { query as q, Expr } from 'faunadb';
export function TypeOf(value: Expr) {
return q.Let(
{
value,
type: q.Let(
[
{ t: null },
{ t: q.If(q.IsString(q.Var('t')), q.Var('t'), q.If(q.IsArray(q.Var('value')), 'array', q.Var('t'))) },

To add the snippets:

  1. Hit > shift + command + p and type snippets (or go look for 2.)
  2. Select Preferences: Open User Snippets
  3. Choose the language type for which you want to add the custom snippet (choosed all, for js/ts/fql files)
  4. Copy/Paste the snippets.json content in there

Currently covered:

  • q.Lambda
  • q.Let
  • q.Var
CreateIndex({
  name: 'ngram_on_users',
  source: {
    collection: Collection('users'),
    fields: {
      search: Query(Lambda('instance', 
          Union(
            Union(Map([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], Lambda('min', NGram(LowerCase(Select(['data', 'first_name'], Var('instance'))), Var('min'), Var('min'))))),
 Union(Map([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], Lambda('min', NGram(LowerCase(Select(['data', 'last_name'], Var('instance'))), Var('min'), Var('min')))))
@gahabeen
gahabeen / HasRoleUDF.js
Last active January 21, 2022 16:36
Managing Roles Memberships in Fauna (DB)
// HasRole - User-Defined Function
CreateFunction({
name: 'HasRole',
body: Query(Lambda(['role', 'ref'], Select(Var('role'), Call('RolesMemberships', [Var('ref')]), false)))
})