Skip to content

Instantly share code, notes, and snippets.

View zackify's full-sized avatar
🤠
coding like crazy

Zach Silveira zackify

🤠
coding like crazy
View GitHub Profile
import { useDispatch } from 'react-redux'
import someAction from 'actions/someAction'
export const useSomeAction = () => {
let {setToast} = useJessesContext()
const dispatch = useDispatch()
return ({message, someOtherActionDataIneed}) => {
dispatch(
someAction({setToast, message, someOtherActionDataIneed})
if (typeof window === 'undefined') {
global.window = new Proxy(
{},
{
get: (_, key) => {
// may need to add new stuff here to account for other method types
return () => global.window;
},
set: target => console.log(target),
}
return (
<div>
<Header />
<Products />
<AddToCart />
<Footer />
</div>
)
@zackify
zackify / Test.js
Created May 10, 2020 01:30
Example loading module vs no module
(function(d) {
var script = d.createElement("script");
script.type = "text/javascript";
script.text =
'import("https://passwordless.app/account/module/integrated.js");window.supportsDynamicImport = true;';
d.getElementsByTagName("head")[0].appendChild(script);
var script2 = d.createElement("script");
script2.type = "text/javascript";
//map and use Form over and over, add a button to add another field to state. All up to you
//Form doesn't render a form element, this way it works in rn and web, and wherever else.
// you can wrap all of them in one if you want.
const App = () => {
let [values, setValues] = React.useState([{name: 'test'}])
return values.map((value, index) => (
<Form
values={values}
# set the version from an env variable in ios
/usr/libexec/Plistbuddy -c "Set CFBundleShortVersionString $BUILD_NUMBER" "ios/cnnrnv2/Info.plist"
#in android, app/build.gradle
# versionName = System.env.BUILD_NUMBER

Keybase proof

I hereby claim:

  • I am zackify on github.
  • I am zackify (https://keybase.io/zackify) on keybase.
  • I have a public key whose fingerprint is 03B5 3C3F A415 039C 2749 BD5F F1B3 BDD4 B320 A804

To claim this, I am signing this object:

export const api = ({ url, headers = {}, body, method }) =>
new Promise(async (resolve, reject) => {
try {
body = JSON.stringify(body);
headers['Content-Type'] = 'application/json';
} catch (e) {}
//intercept before if i want
let token = await storage.get('userToken')
headers.Authorization = token
@zackify
zackify / create-cert.md
Last active October 14, 2019 20:50
Create cert for webpack in one command, mac
"create-cert": "bash -c \"openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout config/server.key -out config/server.crt -subj \"/C=US/ST=Nevada/L=test/O=test/OU=Software/CN=localhost\" -extensions san -config <(echo '[req]'; echo 'distinguished_name=req'; echo '[san]'; echo 'subjectAltName=DNS:localhost,IP:127.0.0.1') && sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain config/server.crt\"",

import { mapValues } from 'lodash';
const authCheck = (resolver, isPublic) => (parent, args, context, info) => {
if (isPublic || context.user) {
return resolver(parent, args, context, info);
}
return ApolloError({ code: 401 });
};
export default (resolvers, publicResolvers = []) =>