Skip to content

Instantly share code, notes, and snippets.

View jasmo2's full-sized avatar

Jaime Molina jasmo2

  • Counterpart
  • All over the World
View GitHub Profile
/*
Vite and styles components using babel
https://stackoverflow.com/a/71453876/26576455
https://github.com/styled-components/babel-plugin-styled-components/issues/350#issuecomment-979873241
npm i babel-plugin-styled-components
*/
export default defineConfig({
// Example auth Context: https://dev.to/shareef/context-api-with-typescript-and-next-js-2m25
import React, { createContext, useContext, useEffect, useState } from 'react';
interface ElementContextType {
prop1?: string | any
}
export const ElementContext = createContext<ElementContextType>({
prop1: 'default',
});
var intervalTime = 2000
var intervalFunc = setInterval(()=> {
const btns = btn = document.getElementsByClassName("Bgi($g-ds-background-like):a")
const likeBtn = btns[0]
likeBtn.click()
}, intervalTime)
"scripts":{
"test:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand --watch",
}
import { useContext } from "react"
export function useContextFactory<T>(name: string, context: React.Context<T>) {
return () => {
const ctx = useContext(context)
if (ctx === undefined) {
throw new Error(
`use${name}Context must be used withing a ${name}ContextProvider.`
)
}
alter table(:qa_job) do
add :body, :jsonb
add :input, :jsonb
add :output, :jsonb
end
@jasmo2
jasmo2 / firebase-runtimeconfig-parser-uploader.js
Last active August 4, 2020 21:59
This script will upload wha is set inside `.runtimeconfig.json` * to firebase functions - jasmo2
/*
* NOTE: this file will upload wha is set inside `.runtimeconfig.json`
* to firebase functions.
*
* To run go to root in the project and run:
* cat .runtimeconfig.json | node ./parser.js
*/
const stdin = process.openStdin()
const spawn = require('child_process').spawn
@jasmo2
jasmo2 / .prettierrc
Last active July 28, 2020 22:02
Common Config files
{
"editorconfig": true,
"trailingComma": "es5",
"semi": false,
"singleQuote": true,
"jsxBracketSameLine": false,
"arrowParens": "always",
"printWidth": 80
}
/*
* in package.json set the next script:
* "update-refs": "node update-refs.js ENVIRONTMENT_A && node update-refs.js ENVIRONTMENT_B && ... && node update-refs.js ENVIRONTMENT_i && git add ."
*/
const fs = require('fs')
const axios = require('axios')
const saveRef = (envFile, ref) => {
const envDev = fs.readFileSync(envFile, {
encoding: 'utf8',
function isFlattenable(value) {
return Array.isArray(value)
}
function flattenImplementation (array, depth = Infinity, isStrict, result = []) {
let index = -1
let length = array.length
while (++index < length) {
var value = array[index]