Skip to content

Instantly share code, notes, and snippets.

@KevinStrong
KevinStrong / .gitignore
Created September 5, 2017 04:38 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@KevinStrong
KevinStrong / ExpoPushTokenRegistrar.tsx
Last active July 16, 2020 21:34
Register an Expo Push Token
// An expo push token is used by our server to send push notifications to our mobile app.
// Once a user has authenticated we need to query expo for the token and store (register) it with our backend.
// This code registers an expo token when:
// a) A users authenticates.
// b) A user who has previously denied push notification permissions grants them and then opens the app.
// c) A user who is authenticated and has not registered opens the app.
export const registerExpoTokenOperation = graphql`
mutation ExpoPushTokenRegistrarRaw_RegisterExpoTokenMutation($input: AddExpoPushTokenInput!) {
addExpoPushToken(input: $input) {
@KevinStrong
KevinStrong / PushNotifications.tsx
Last active July 16, 2020 21:34
Listen for incoming push notifications
import { Notification } from "expo/build/Notifications/Notifications.types";
import { Notifications } from "expo";
interface PushNotificationData {
readonly id: string;
readonly actionType: PushNotificationAction;
readonly linkedMeritId: string;
}
const handleNotification = (notification: Notification): void => {
@KevinStrong
KevinStrong / SendExpoPushNotificationEff.scala
Created August 31, 2020 22:58
Sends a push notification using Expo
/**
* Send push notifications
* <p>
* If you don't get an ExpoClientError, you are guaranteed there will be a ticket for each message sent,
* in corresponding order they were passed in.
* @param notificationRequests a Seq of ExpoPushNotificationRequests, one for each push notification you want to send.
* @return Either an ExpoClientError if the request failed, or a list of TicketResponses
* which document the status of each push notification sent
*/
def sendExpoPushNotificationsEff(
@KevinStrong
KevinStrong / GetPushNotificationReceiptsEff.scala
Created August 31, 2020 23:00
Process Expo push notification tickets to check the status of push notification
/**
* Get push notification receipts from Expo for each push notification ticket id.
* <p>
* A push notification receipt contains final information about the status of a push notification, including
* if the push notification sent successsfully or if any errors occurred.
* <p>
* If the ticket id does not exist on the server, it will not show up in the result map
* @param ticketIds
* @return Either an ExpoClientError if the request failed, or a map of ticket ids to ReceiptResponses,
* where each String represents the ticketId and the ReceiptResponse represents
@KevinStrong
KevinStrong / Sandbox.go
Created January 15, 2021 00:44
composition in go
package main
import (
"math/rand"
"time"
)
type Animal interface {
isHappy() bool
eat() string
@KevinStrong
KevinStrong / main.go
Created February 11, 2021 02:18
OIDC-example
package main
import (
"bytes"
"encoding/base64"
"encoding/json"
"fmt"
"html/template"
"io/ioutil"
"log"
@KevinStrong
KevinStrong / 2_events_and_kiosks.yaml
Last active November 8, 2021 21:45
A liquibase yaml file to create kiosk and event tables
databaseChangeLog:
- changeSet:
- id: 2-create-events-and-kiosks-table
author: kevin@gomerits.com
changes:
- createTable:
tableName: events
schemaName: checkin
columns:
- column:
@KevinStrong
KevinStrong / 3_join.yaml
Last active February 15, 2022 00:39
Create a join table between kiosks and events
databaseChangeLog:
- changeSet:
- id: 3-create-join-table
author: kevin@gomerits.com
changes:
- createTable:
tableName: kiosk_events
remarks: A join table between kiosks and events
schemaName: checkin
columns:
@KevinStrong
KevinStrong / model.go
Last active November 29, 2021 16:25
The golang model for kiosk, events and kioskEvents
package join
import "gorm.io/gorm"
type Event struct {
gorm.Model
Kiosks []Kiosk `gorm:"many2many:kiosk_events"`
Name string
}