Skip to content

Instantly share code, notes, and snippets.

View sudomann's full-sized avatar
🌆
Night Owl

Willy Njundong sudomann

🌆
Night Owl
View GitHub Profile
services:
init_ensure_models:
image: alpine:latest
volumes:
- ./worker/models:/worker/models
entrypoint: >
/bin/sh -c "
if [ ! -f /worker/models/nlp/my_model.gguf ]; then
echo 'Downloading models...';
mkdir -p /worker/models/nlp/ &&
On yupprotocol.org:
- Yup Racing tile is set to snap to an id that does not exist on the page - but the content is there
On app.yup.io:
- The extention button in the side menu takes you to the chrome webstore no matter what browser you're using
- I don't know enough about UX to say this is a bad thing, but I'm curious, why are the navigation menus on yup.io and app.yup.io on opposite sides
- rendering performance in chromium browsers is about okay, but gets worse in FF
- There is a log out button available (which appears to do nothing) at the same time as a sign up/login button
General:
> docker run -it alpine:latest sh
/ # apk add --update curl
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz
(1/5) Installing ca-certificates (20191127-r5)
(2/5) Installing brotli-libs (1.0.9-r3)
(3/5) Installing nghttp2-libs (1.42.0-r1)
(4/5) Installing libcurl (7.76.1-r0)
(5/5) Installing curl (7.76.1-r0)
Executing busybox-1.32.1-r6.trigger
isEnabled = async () => {
console.log("isEnabled() running");
return SecureStore.getItemAsync(this._storageKey)
.then((value) => {
// no previously stored/specified value
if (value === null) Promise.reject();
return value === BooleanSetting.States.ON;
})
.catch(() => {
console.error("boolean seting isEnabled throwing :(");
@sudomann
sudomann / etl.js
Last active December 25, 2020 20:02
/**
* ETL function to gather all person type contacts from device
* @returns {Promise<{ name: string, nickname: string, maidenName: string, phoneNumbers: string[], emails: string[] }[]>} An promise resolved to an array of 0 or more transformed contacts
*/
export const extractAndTransformContacts = async () =>
Contacts.getContactsAsync({
fields: QUERY_FIELDS,
pageSize: 0,
}).then(({ data }) => {
const transformedContacts = produceContacts(data);
export default class ChoiceSetting {
static storageKey = undefined;
static label = undefined;
static defaultValue = undefined;
static set defaultValue(value) {
if (failsValidation(value))
throw new Error();
this.defaultValue = value;
}
const transformContact = (contact) => {
const obj = {};
[
Contacts.Fields.Name,
Contacts.Fields.Nickname,
Contacts.Fields.MaidenName,
].forEach((fieldName) => {
if (contact[fieldName]) obj[fieldName] = contact[fieldName];
});
import { authClient } from "./auth-client";
import { httpClient } from "./http-client";
import { IllegalModificationError } from "./errors";
export const Transport = {
get Auth() {
return authClient;
},
get Http() {
const tokenChecker = (config) => {
if (!someCondition) {
try {
return somePossiblyThrowingAsync()
.then(successCallback);
} catch (e) {
switch (true) {
case e instanceof AccessTokenRefreshError: {
console.warn('AccessTokenRefreshError');
break;
const tokenChecker = (config) => {
if (Transport.Http.isAccessTokenValid(config)) return config;
try {
Transport.Auth.fetchNewAccessTokenAsync().then((access) => {
/* Transport.Http.updateAuthorizationHeader accepts a token string
then formats it into a proper Authorization header string.
It then assigns that value to the axios instance's .defaults.headers.common.Authorization
for future requests.
Finally it returns that formatted header string for use by the caller.
In this case, I want to add it to the current request before it goes out