Skip to content

Instantly share code, notes, and snippets.

@chunkzer
chunkzer / make-component.js
Created August 6, 2021 01:46
Create all the associated boilerplate with a new react component
// include node fs module
const fs = require('fs');
const { writeFile, mkdir } = fs;
const makeComponentBoilerPlayer = async (args) => {
const [,, name, filepath] = args;
const directoryName = `${filepath}${name}`
await mkdir(directoryName, () => null);
const componentFileName = `${filepath}${name}.tsx`;
// dummy data
const peopleArray = ['Alice', 'Chris', 'Tom Hanks', 'Edgar', 'John'];
// dummy relations
const hardcodedRelations = {
'Chris': {
'John:': true,
'Tom Hanks': true,
},
'John': {
/**
* @example A hook for setting Error Messages
* import 'hooks/useError';
*
* @param {String} defaultErrorMessage
*/
export default (defaultErrors = []) => {
const [errors, setError] = useState(defaultErrors);
const raiseError = message => setError([...errors, message]);
I don't have serious projects on public repos. : (.
Here's one of the simple illustrative examples I've written for a React meet up I host:
https://github.com/chunkzer/react-cafe-memory-game
https://www.meetup.com/React-Cafe/
I usually stream code alongs @ https://www.twitch.tv/chunkzer/videos
@chunkzer
chunkzer / gist:366f0520115b5647aa9b
Created February 20, 2015 21:12
capi en haskell
import Data.List.Split
import Data.List
import Data.Char
subAbc = ([" "] ++ [" "] ++ splitEvery 3 ['A'..'O']) ++ [['P'..'S']] ++ [['T'..'V']] ++ [['W'..'Z']]
indexmap a = map (findIndices (==a)) subAbc
finder a = (findIndices (not . null) (indexmap a) !! 0 , (concat (indexmap a))!!0)
codificador x = map (intToDigit) (replicate ((snd x)+1) (((fst x))))
espacios [] = []
espacios (x:y:xs) = if (x!!0 == y!!0) then x:" ":espacios(y:xs) else x:espacios(y:xs)
espacios [x] = x:[]