Skip to content

Instantly share code, notes, and snippets.

View ConradSulzer's full-sized avatar

Conrad Sulzer ConradSulzer

View GitHub Profile
@ConradSulzer
ConradSulzer / func_component_template
Created November 11, 2021 16:28
React Native Functional Component Template
import React, {useState, useEffect} from 'react'
import {StyleSheet, View} from 'react-native'
const MyFunctionalComponent = (props) => {
useEffect(() => {
//on load logic
}, [])
return (
<View style={{flex: 1}}>
defmodule Fillogic.Helpers.ErrorHelpers do
@moduledoc """
A module for general error helpers
"""
import Ecto.Changeset, only: [traverse_errors: 2]
def error_message_builder(errors) do
errors
|> find_errors()
|> format_errors()
"workbench.colorCustomizations": {
"terminal.background":"#1D2021",
"terminal.foreground":"#A89984",
"terminalCursor.background":"#A89984",
"terminalCursor.foreground":"#A89984",
"terminal.ansiBlack":"#1D2021",
"terminal.ansiBlue":"#0D6678",
"terminal.ansiBrightBlack":"#665C54",
"terminal.ansiBrightBlue":"#0D6678",
"terminal.ansiBrightCyan":"#8BA59B",

Keybase proof

I hereby claim:

  • I am conradsulzer on github.
  • I am conradsulzer (https://keybase.io/conradsulzer) on keybase.
  • I have a public key ASAEuPXUdh5kGkz6Nd1Y5W0LtGqvarRy-Lc8Jri2O4B4wwo

To claim this, I am signing this object:

@ConradSulzer
ConradSulzer / deepQueryObj.js
Created February 9, 2021 22:54
Query Object Recursively
//pathArray is an array where array[0] is the first property in the query path, array[1] the next property, etc.
//Particularly helpful if you have the path to the value you want in string form. You can use split() to get the array form the string
//If you may have the string 'food.type.apple'
//use split('.') to get the string path to the value want in array form and pass to the queryObject function
//obj is the object you want to run the query against
queryObject: function (pathArray, obj) {
//Takes path as an array and retreives the value
const [head, ...rest] = pathArray;
let value = ''
@ConradSulzer
ConradSulzer / deepSetOBj
Last active January 28, 2021 16:18
Set nested values in objects
// Use to set nested values in an object. If a property doesn't exist yet in the object it will be created.
//** 'obj' is the obj you want to set the value in, can be an empty object if you want to populate a new one.
//** 'array' is the path to the value. I typically have the path represented as a string
// and get the array from string.split('.'). E.x. array = ['set', 'value', 'here'].
//** 'value' is the value you want to set
const deepSetObj = (obj, array, value) => {
const [head, ...rest] = array
if(rest.length <= 0) {