This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react-native'; | |
| var { | |
| AsyncStorage | |
| } = React; | |
| var LocalStorage = { | |
| get: function (key) { | |
| return AsyncStorage.getItem(key).then(function(value) { | |
| return JSON.parse(value); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "scripts": { | |
| "dev": "node .dev/webpack.dev.server.js", | |
| "dev-prod": "node .dev/webpack.dev.server.js --production", | |
| "build": "rimraf ./dist && webpack --config .dev/webpack.config.production.js --colors", | |
| }, | |
| "devDependencies": { | |
| "@babel/core": "7.0.0-beta.38", | |
| "@babel/plugin-proposal-class-properties": "7.0.0-beta.38", | |
| "@babel/plugin-proposal-decorators": "7.0.0-beta.38", | |
| "@babel/plugin-transform-classes": "7.0.0-beta.38", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function getMostPopularPostSlugs({ | |
| limit, | |
| exclude, | |
| }: { | |
| limit: number | |
| exclude: Array<string> | |
| }) { | |
| const result = await prisma.postRead.groupBy({ | |
| by: ['postSlug'], | |
| _count: true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { pbkdf2: deriveKey } = require("pbkdf2"); | |
| const crypto = require("crypto"); | |
| const DERIVATION_ROUNDS = 200000; | |
| const HMAC_KEY_SIZE = 32; | |
| const PASSWORD_KEY_SIZE = 32; | |
| function pbkdf2(password, salt, rounds, bits) { | |
| return new Promise((resolve, reject) => { | |
| deriveKey(password, salt, rounds, bits / 8, "sha256", (err, key) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // create context with no upfront defaultValue | |
| // without having to do undefined check all the time | |
| function createCtx<A>() { | |
| const ctx = React.createContext<A | undefined>(undefined) | |
| function useCtx() { | |
| const c = React.useContext(ctx) | |
| if (!c) throw new Error("useCtx must be inside a Provider with a value") | |
| return c | |
| } | |
| return [useCtx, ctx.Provider] as const |
OlderNewer