I hereby claim:
- I am norwae on github.
- I am terra_nova (https://keybase.io/terra_nova) on keybase.
- I have a public key ASClXPcKjReG464iKtbjqnZ7xUe5SQprSZar1wUWW2fxmwo
To claim this, I am signing this object:
| [package] | |
| name = "badness" | |
| version = "0.1.0" | |
| authors = ["Norwae"] | |
| edition = "2018" | |
| # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
| [dependencies] | |
| tokio = { version = "0.2.13", features = ["full"]} |
| object WorkPeriods { | |
| val listeners = CopyOnWriteArraySet<UpdateListener<List<Workperiod>>>() | |
| var workperiods by UpdateDispatcher(emptyList(), listeners) | |
| private set | |
| fun init() { | |
| Bookings.bookingListeners += object: UpdateListener<List<Booking>> { | |
| override fun onUpdated(oldValue: List<Booking>, newValue: List<Booking>) { | |
| workperiods = constructWorkPeriods(newValue) | |
| } |
| rules_version = '2'; | |
| service cloud.firestore { | |
| match /databases/{database}/documents { | |
| match /{document=**} { | |
| // do not allow any access by default | |
| allow read, write: if false; | |
| } | |
| match /users/{uid} { | |
| // each user may access and change their user doc | |
| allow read, write: if uid == request.auth.uid |
| class CompanySelector { | |
| val companyChangeListeners = CopyOnWriteArraySet<UpdateListener<CompanyMembership>>() | |
| // the dispatcher delegate automatically emits an event to all listeners whenever the value is changed | |
| var currentCompany by UpdateDispatcher(CompanyMembership.NoCompany, companyChangeListeners) | |
| private set | |
| var allCompanies = emptyList<CompanyMembership>() | |
| private set | |
| val firestore = FirebaseFirestore.getInstance() | |
| val userDocument = firestore.document("/users/$userId") | |
| userDocument.addSnapshotListener { snapshot, err -> | |
| if (err == null && snapshot != null) { | |
| selectedId = snapshot.get("currentCompany").toString() | |
| refreshCurrentCompany() | |
| } else { | |
| Log.e(TAG, "Company select listener reported refresh error", err) | |
| } | |
| } |
I hereby claim:
To claim this, I am signing this object:
| type IgnoredParameter struct{} | |
| func ServeCron(ctx context.Context, ignore IgnoredParameter) error { | |
| var ( | |
| err error | |
| k *datastore.Key | |
| wg sync.WaitGroup | |
| target DeadMansTrigger | |
| ) |
| var baseURL string | |
| func init() { | |
| // unfortunately, there seems to be no simple env property reporting the unmangled invocations URL, so | |
| // we build it from its parts | |
| projectId := os.Getenv("GCP_PROJECT") | |
| region := os.Getenv("FUNCTION_REGION") | |
| name := os.Getenv("FUNCTION_NAME") | |
| baseURL = fmt.Sprint("https://", region, "-", projectId, ".cloudfunctions.net/", name) |
| const Kind = "DMT" | |
| type DeadMansTrigger struct { | |
| Id string `json:"id" datastore:",noindex"` | |
| DueToFire time.Time `json:"due"` | |
| HoursBetweenFire int `json:"hoursBetweenFire" datastore:",noindex"` | |
| Checkins []time.Time `json:"checkins" datastore:",noindex"` | |
| FireURL string `json:"fireURL" datastore:",noindex"` | |
| FirePayload string `json:"firePayload" datastore:",noindex"` | |
| } |
| var store *datastore.Client | |
| func init() { | |
| projectId := os.Getenv("GCP_PROJECT") | |
| client, err := datastore.NewClient(context.Background(), projectId) | |
| if err != nil { | |
| log.Fatalf("Could not create datastore client: %v", err) | |
| } | |
| } |