Skip to content

Instantly share code, notes, and snippets.

View bbsmithy's full-sized avatar
🎯
Flat out

Brian Smith bbsmithy

🎯
Flat out
View GitHub Profile
@bbsmithy
bbsmithy / NotificationsWrapper.ts
Created January 19, 2023 17:17
NotificationsWrapper component for handling notifications setup and interactions in React Native Expo
import * as Notifications from 'expo-notifications';
import { useEffect, useRef } from "react";
import { Platform } from "react-native";
import * as Device from "expo-device";
import { useDispatch, useSelector } from 'react-redux';
import { UserSlice } from '../state/reducers/UserReducer';
import { navigateWhenReady } from '../navigation';
import { RootState } from '../state/store';
import { remindersList, RemindersSlice } from '../state/reducers/RemindersReducer';
import { DEFAULT_THOUGHT_EXCERCISE_REMINDER } from '../state/middleware/NotificationsMiddleware';
@bbsmithy
bbsmithy / NotificationsMiddleware.ts
Created January 19, 2023 14:59
Redux middleware for adding notification reminders
import { PayloadAction } from "@reduxjs/toolkit";
import * as Notifications from "expo-notifications";
export type ReminderType = "daily" | "weekly" | "every_other_day";
export type Reminder = {
type: ReminderType;
title: string;
subTitle: string;
optionKey: string;
@bbsmithy
bbsmithy / compressor.py
Last active October 23, 2018 20:10
Python image compression for AWS lamda, with S3 triggers
from __future__ import print_function
import boto3
from botocore.client import Config
import os
import sys
import uuid
from PIL import Image
import PIL.Image
@bbsmithy
bbsmithy / xml2json.js
Created December 8, 2017 11:47
Function that parses xml to json
xmlToJson(xml) {
// Create the return object
let obj = {};
let attribute;
let item;
if (xml.nodeType == 1) {
// element
// do attributes
if (xml.attributes.length > 0) {