Skip to content

Instantly share code, notes, and snippets.

View sethdavis512's full-sized avatar
🤖

Seth Davis sethdavis512

🤖
View GitHub Profile
@cjavilla-stripe
cjavilla-stripe / value-based-saas-pricing-seed.json
Last active January 28, 2023 14:46
Stripe CLI fixture for creating value based pricing Stripe test data
{
"_meta": {
"template_version": 0
},
"fixtures": [
{
"name": "startup_product",
"path": "/v1/products",
"method": "post",
"params": {
@BjornDCode
BjornDCode / gist:5cb836a6b23638d6d02f5cb6ed59a04a
Created February 3, 2020 11:58
Tailwind - Fixed sidebar, scrollable content
// Source: https://twitter.com/calebporzio/status/1151876736931549185
<div class="flex">
<aside class="h-screen sticky top-0">
// Fixed Sidebar
</aside>
<main>
// Content
</main>
@gokulkrishh
gokulkrishh / useful-npx-commands.md
Last active November 24, 2023 04:25
List of useful npx (Node Package Runner) commands (https://git.io/useful-npx-commands)

NPX (NPM Package Runner) Commands

List of useful npx (NPM Package Runner) commands.

What is NPX?

Using NPX we can execute/run node binaries without the need to install it locally or globally.

Commands

function RadioGroup({ onChange, name, children }) {
const [state, inputProps] = useRadioGroup(name)
return (
<Context.Provider value={inputProps}>
{children}
</Context.Provider>
)
}
function RadioInput(props) {
import { useState, useEffect } from 'react';
// Usage
function App() {
// Call our hook for each key that we'd like to monitor
const happyPress = useKeyPress('h');
const sadPress = useKeyPress('s');
const robotPress = useKeyPress('r');
const foxPress = useKeyPress('f');
@myrfy001
myrfy001 / Highlight DOM elements (include sub DOM) when mouse hover over it in Chrome or Firefox using devTools.md
Created May 14, 2018 02:59
Highlight DOM elements (include sub DOM) when mouse hover over it in Chrome or Firefox using DevTools

Paste the following code into the console panel of the DevTools window of Chrome or Firefox.

The style sheet came from (Web Scraper)[http://webscraper.io/] plugin for Chrome

It is useful for analyse a page layout and you can extend it to select preferred dom elements.

function addStyleString(str) {
    var node = document.createElement('style');
@mritzco
mritzco / plopfile.js
Created March 8, 2018 08:09
Custom action for plop. Appends data to JSON files
const fs = require('fs-extra');
const methods = {}, priv = {};
// Private methods to do string replacement. Not optimized and cummulative trying to keep it simple.
// far better options here: https://stackoverflow.com/questions/5069464/replace-multiple-strings-at-once
priv.replaceObj = function(value, vars) {
let obj = value;
Object.keys(obj).forEach(function(item) {
obj[item] = priv.replaceStr(obj[item], vars);
});
return obj;
@fokusferit
fokusferit / enzyme_render_diffs.md
Last active April 15, 2024 09:41
Difference between Shallow, Mount and render of Enzyme

Shallow

Real unit test (isolation, no children render)

Simple shallow

Calls:

  • constructor
  • render
// prop callback
class Compoennt {
render() {
return (
<div>
<Thing onChange={(val) => {
this.setState({ val1: val })
}}/>
<Thing onChange={(val) => {
this.setState({ val2: val })
@wesbos
wesbos / async-await.js
Created February 22, 2017 14:02
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}