Skip to content

Instantly share code, notes, and snippets.

View Grsmto's full-sized avatar

Adrien Denat Grsmto

View GitHub Profile
@Grsmto
Grsmto / CustomArrayFunctions.js
Last active June 23, 2021 16:54
Sanity custom ArrayFunctions component to limit length of Arrays
// Simple implementation of https://github.com/sanity-io/sanity/blob/21af6baffe88d57db32d0a05e048ef7d3d671523/packages/%40sanity/form-builder/src/inputs/ArrayInput/ArrayFunctions.tsx
import React from "react";
import DropDownButton from "part:@sanity/components/buttons/dropdown";
import Button from "part:@sanity/components/buttons/default";
import ButtonGrid from "part:@sanity/components/buttons/button-grid";
import styles from "./styles/ArrayInput.css";
export default class ArrayFunctions extends React.Component {
handleDropDownAction = (menuItem) => {
@Grsmto
Grsmto / sanity-cheatsheet.md
Last active July 13, 2020 20:12
Sanity cheatsheet

Sanity.io CheatSheet

Copy content of document in clipboard

> sanity documents get document-id | pbcopy

Edit document from CLI

First make sure to define your editor using EDITOR=code (for vscode).

> sanity documents create --id documentId --watch --replace

@Grsmto
Grsmto / useIsDragged.js
Last active December 14, 2021 17:58
React Hook to define if a mouse event is a drag or not
import React from "react"
export default function useIsDragged(ref, offset = 5) {
const isDragged = React.useRef(false)
const isDown = React.useRef(false)
const distance = React.useRef(0)
const mousePos = React.useRef({
x: 0,
y: 0,
})
@Grsmto
Grsmto / react-table.d.ts
Created March 6, 2019 12:59
React Table v7 TS typings definition
// Type definitions for react-table 7
// Project: https://github.com/tannerlinsley/react-table#readme
// Definitions by: Grsmto <https://github.com/grsmto>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
declare module 'react-table' {
export type Cell = {
render: (type: string) => any;
getCellProps: () => any;
column: Column;
@Grsmto
Grsmto / next.config.js
Created June 15, 2018 08:39
Next.js support for css-modules & normal css at the same time, same behaviour as CRA
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const cssLoaderConfig = require('@zeit/next-css/css-loader-config');
const commonsChunkConfig = (config, test = /\.css$/) => {
config.plugins = config.plugins.map(plugin => {
if (
plugin.constructor.name === 'CommonsChunkPlugin' &&
// disable filenameTemplate checks here because they never match
// (plugin.filenameTemplate === 'commons.js' ||
// plugin.filenameTemplate === 'main.js')
@Grsmto
Grsmto / settings.json
Created February 20, 2018 11:30
Sublime Text to Visual Studio Code settings
{
"editor.minimap.enabled": false,
"workbench.editor.labelFormat": "short",
"workbench.editor.tabSizing": "shrink",
"workbench.editor.enablePreview": false,
"editor.formatOnPaste": true,
"workbench.editor.showIcons": false,
}
@Grsmto
Grsmto / prismic-prepare-translations.js
Created December 8, 2017 13:09
Node.js script to prepare files for translation on Prismic.io
var fs = require('fs');
var dirPath = './imports';
var lang = 'de-de';
var files = fs.readdirSync(dirPath).filter(item => !(/(^|\/)\.[^\/\.]/g).test(item));
files.forEach(function(file) {
fs.readFile(dirPath + '/' + file, function(error, data) {
if (error) {
ffmpeg -i video.mp4 -vf scale=1280x720 -b:v 1024k \
-minrate 512k -maxrate 1485k -tile-columns 2 -g 240 -threads 8 \
-quality good -crf 33 -c:v libvpx-vp9 \
-pass 1 -speed 4 -strict -2 video.webm && \
ffmpeg -i video.mp4 -vf scale=1280x720 -b:v 1024k \
-minrate 512k -maxrate 1485k -tile-columns 2 -g 240 -threads 8 \
-quality good -crf 33 -c:v libvpx-vp9 \
-pass 2 -speed 4 -strict -2 -y video.webm
var path = require('path');
var autoprefixer = require('autoprefixer');
var postcssFlexbugsFixes = require('postcss-flexbugs-fixes');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
var WatchMissingNodeModulesPlugin = require('../scripts/utils/WatchMissingNodeModulesPlugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var paths = require('./paths');
@Grsmto
Grsmto / wr-reversepathdirection.js
Created July 16, 2015 15:44
Reverse a path in Adobe Illustrator
//////////////////////////////////////////////////////////// english //
// -------------------------------
// -=> WR-reversePathDirection <=-
// -------------------------------
//
// A Javascript for Adobe Illustrator
// by Wolfgang Reszel (ai-js@rumborak.de)
//
// Version 0.2 from 1.12.2004
//