Skip to content

Instantly share code, notes, and snippets.

@joshsalverda
joshsalverda / useFieldArray.js
Last active May 22, 2023 09:49
Custom useFieldArray hook for formik using immutability-helper
import {useCallback, useRef, useEffect} from 'react'
import {useField, useFormikContext} from 'formik'
import update from 'immutability-helper'
const useFieldArray = props => {
const [field, meta] = useField(props)
const fieldArray = useRef(field.value)
const {setFieldValue} = useFormikContext()
useEffect(() => {
// create a bookmark and use this code as the URL, you can now toggle the css on/off
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3
javascript: (function() {
var elements = document.body.getElementsByTagName('*');
var items = [];
for (var i = 0; i < elements.length; i++) {
if (elements[i].innerHTML.indexOf('* { background:#000!important;color:#0f0!important;outline:solid #f00 1px!important; background-color: rgba(255,0,0,.2) !important; }') != -1) {
items.push(elements[i]);
}
}
@undefobj
undefobj / index.js
Last active August 17, 2022 18:28
Calling AppSync from Lambda
const https = require('https');
const AWS = require("aws-sdk");
const urlParse = require("url").URL;
const appsyncUrl = process.env.API_BACKENDGRAPHQL_GRAPHQLAPIENDPOINTOUTPUT;
const region = process.env.REGION;
const endpoint = new urlParse(appsyncUrl).hostname.toString();
const graphqlQuery = require('./query.js').mutation;
const apiKey = process.env.API_KEY;
exports.handler = async (event) => {
@CodyReichert
CodyReichert / react-es6-flow-emacs-configuration.md
Last active September 26, 2023 05:56
Configuring Emacs for react, es6, and flow

Configuring Emacs for react, es6, and flow

For a while, JSX and new es6 syntax had flaky support in emacs, but there's been huge work on a lot of packages. Using emacs for JavaScript with React, ES6, and Flow (or Typescript, etc) is really easy and powerful in Emacs these days.

This is how you can work on modern web development projects with full support for tooling like JSX, Flow types, live eslint errors, automatic prettier.js formatting, and more.

Set up web-mode

web-mode provides most of the underlying functionality, so a huge shout-out to the maintainer(s) there.

@diegozr1
diegozr1 / fintech_api_list.md
Last active December 20, 2023 17:51
Curated list of Mexican Fintech APIs
import numpy as np
def vectorize(x):
# vectorize a string
if len(x) > 1:
return np.sum([vectorize(c) for c in x], axis=0)
if x == '.':
i = 27
elif x == ' ':
i = 26
@veuncent
veuncent / create_wagtail_pages_through_migration
Last active August 26, 2021 07:39
Set wagtail (home)pages programmatically during Django Migrations
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
from wagtail.wagtailcore.models import Page, Site
def forwards_func(apps, schema_editor):
HomePage = apps.get_model('website', 'HomePage')
@IBestuzhev
IBestuzhev / .pylint.py
Last active February 13, 2019 05:01
Pylint for remote projects
#!/usr/bin/env python3
import subprocess
import sys
path = sys.argv[-1]
if path.startswith('/path/to/my/local/source/folder/'):
path = path.replace('/path/to/my/local/source/folder/', '/app/folder/')
subprocess.run(['docker-compose', 'exec', '-T', 'cross', 'sh', '-c',
@robertpainsi
robertpainsi / commit-message-guidelines.md
Last active April 25, 2024 13:38
Commit message guidelines

Commit Message Guidelines

Short (72 chars or less) summary

More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).

Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
@cdemers
cdemers / Installing a Go development environment on Mac OS for beginners.md
Last active June 21, 2020 20:08
How to install a functional Go development environment on MacOS with Atom and all the bells and whistles.

Warning! This doc is pretty outdated, I'm rewriting it right now and I'll update this as soon as it's done.


Installing a Go development environment on Mac OS for Beginners

Installing Go

First, install the Go compiler from Google's Go Website: https://golang.org/dl/