Skip to content

Instantly share code, notes, and snippets.

View bgrand-ch's full-sized avatar
🙂
An idea, create it.

Benjamin Grand bgrand-ch

🙂
An idea, create it.
View GitHub Profile
@waaronking
waaronking / index.vue
Created June 23, 2020 10:44
TipTap Align-Text Example
<!-- This file is mainly pseudo code with parts copied from a working project to illustrate how tiptap-aligntext.plugin.js can be implemented into your project -->
<template>
<div>
<editor-menu-bar :editor="editor" v-slot="{ commands }">
<div class="menubar">
<i class="fas fa-align-left" :class="{ 'is-active': editor.activeMarkAttrs.aligntext.align === 'left' }" @click="commands.aligntext({ align: 'left' })"></i>
<i class="fas fa-align-center" :class="{ 'is-active': editor.activeMarkAttrs.aligntext.align === 'center' }" @click="commands.aligntext({ align: 'center' })"></i>
<i class="fas fa-align-right" :class="{ 'is-active': editor.activeMarkAttrs.aligntext.align === 'right' }" @click="commands.aligntext({ align: 'right' })"></i>
<i class="fas fa-align-justify" :class="{ 'is-active': editor.activeMarkAttrs.aligntext.align === 'justify' }" @click="commands.aligntext({ align: 'justify' })"></i>
@damiencarbery
damiencarbery / allow-wc-rest-api-queries-with-ip-check.php
Last active November 18, 2021 18:44
Disable WooCommerce REST API authentication: Override WooCommerce capability check so that all REST API queries are allowed. https://www.damiencarbery.com/2019/07/disable-woocommerce-rest-api-authentication/
<?php
/*
Plugin Name: Disable WooCommerce REST API authentication
Plugin URI: https://www.damiencarbery.com/2019/07/disable-woocommerce-rest-api-authentication/
Description: Override WooCommerce capability check so that all REST API queries from specified IP are allowed
Author: Damien Carbery
Version: 0.1
*/
@ruandre
ruandre / s3-bucket-exists.js
Last active February 8, 2022 05:36
Check if S3 bucket exists using AWS SDK JavaScript Node.js
const AWS = require('aws-sdk')
const s3 = new AWS.S3()
const BUCKET_NAME = 'MyBucket'
async function main() {
try {
const data = await s3.headBucket({ Bucket: BUCKET_NAME }).promise()
return `Bucket "${BUCKET_NAME}" exists`
@owencm
owencm / blob-to-image.js
Created January 12, 2019 18:01
Convert a blob to an image with JavaScript (e.g. to render blob to canvas)
const blobToImage = (blob) => {
return new Promise(resolve => {
const url = URL.createObjectURL(blob)
let img = new Image()
img.onload = () => {
URL.revokeObjectURL(url)
resolve(img)
}
img.src = url
})
@marcel-ploch
marcel-ploch / keyboardevents.js
Last active October 11, 2019 10:40
Keyboard Events for IOs in NativeScript
// Keyboard up event on ios
if (application.ios) {
// First Event is Catched before the Keyboard Jumps Up
// We Save the Height of the Keyboard for the Positioning of the LayoutElement
application.ios.addNotificationObserver(UIKeyboardWillShowNotification, (event) => {
// console.log('WillShow', typeof event.userInfo, event.userInfo.valueForKey(UIKeyboardFrameEndUserInfoKey).CGRectValue.size.height);
// console.log(this.textView.ios.contentSize);
this.contentSizeStartValue = event.userInfo.valueForKey(UIKeyboardFrameEndUserInfoKey).CGRectValue.size.height + 10;
});
// Second Event is Catched when the Keyboard is Up to Reposition our Element
@DavidWells
DavidWells / netlify.toml
Last active February 7, 2024 08:50
All Netlify.toml & yml values
[Settings]
ID = "Your_Site_ID"
# Settings in the [build] context are global and are applied to all contexts unless otherwise overridden by more specific contexts.
[build]
# This is the directory to change to before starting a build.
base = "project/"
# NOTE: This is where we will look for package.json/.nvmrc/etc, not root.
# This is the directory that you are publishing from (relative to root of your repo)
@steven2358
steven2358 / ffmpeg.md
Last active May 10, 2024 20:57
FFmpeg cheat sheet
@NigelEarle
NigelEarle / Knex-Migrations-Seeding.md
Last active March 23, 2024 09:04
Migration and seeding instructions using Knex.js!

Migrations & Seeding

What are migrations??

Migrations are a way to make database changes or updates, like creating or dropping tables, as well as updating a table with new columns with constraints via generated scripts. We can build these scripts via the command line using knex command line tool.

To learn more about migrations, check out this article on the different types of database migrations!

Creating/Dropping Tables

@Orangestar12
Orangestar12 / ffmpeg.md
Last active February 13, 2024 08:09
quick ffmpeg cheat sheet

If this is too much for you, check out ffmpeg.lav.io

These are a few quick easy ffmpeg command lines that can be used to make oft-used video formats. I use them a lot so I wrote them down in a txt file but I converted it to markdown to upload here and access on all my pcs.

Feel free to use 'em. I've gathered them through superuser posts, wiki trawls, and personal experience.


General notes

@codediodeio
codediodeio / database.rules.json
Last active January 28, 2024 19:07
Common Database Rules for Firebase
// No Security
{
"rules": {
".read": true,
".write": true
}
}