I started using React 3.5 years ago, and I still love it. It was such a well-designed solution that not much has changed since then, only superficial stuff like naming. What I learned then is still wholly applicable today because it's such a good idea (although now you can choose from many other libraries). On top of that, we now benefit from an entirely new architecture (fiber) without changing much.
This file contains 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 { useLoaderData, Link, useSearchParams } from 'remix'; | |
import { parseISO, format } from 'date-fns'; | |
import groupBy from 'lodash/groupBy'; | |
let PAGE_SIZE = 5; | |
function safeParseInt(str) { | |
let parsed = parseInt(str); | |
return isNaN(parsed) ? 0 : parsed; | |
} |
This file contains 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
// Uses Buffer from https://github.com/feross/buffer | |
function toArrayBuffer(buffer) { | |
return buffer.buffer.slice( | |
buffer.byteOffset, | |
buffer.byteOffset + buffer.byteLength | |
); | |
} | |
async function run() { |
This file contains 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 async_hooks = require('async_hooks'); | |
let store = new Map(); | |
let promiseStorageHook = async_hooks.createHook({ | |
init(id, type, triggerId, resource) { | |
if (store.get(triggerId)) { | |
if (type === 'PROMISE') { | |
store.set(id, store.get(triggerId)); | |
} |
This file contains 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'; | |
import { View, Text, ScrollView, TouchableOpacity } from 'react-native'; | |
let NamespaceContext = React.createContext(undefined); | |
export default class ExamplePage extends React.Component { | |
constructor() { | |
super(); | |
this.state = { currentMonth: 1 }; | |
} |
This file contains 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 Timestamp from './timestamp'; | |
function getKeys(trie) { | |
return Object.keys(trie).filter(x => x !== 'hash'); | |
} | |
function keyToTimestamp(key) { | |
// 16 is the length of the base 3 value of the current time in | |
// minutes. Ensure it's padded to create the full value | |
let fullkey = key + '0'.repeat(16 - key.length); |
This file contains 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
// UPDATE: don't use this. when it re-partitions the list when time moves forward, it does not correctly keep hashes | |
// Use a real merkle tree instead: https://gist.github.com/jlongster/f431b6d75ef29c1a2ed000715aef9c8c | |
import Timestamp from './timestamp'; | |
// This is a compact data structure that keeps track of a list of | |
// hashes (representing messages) over a range of time in order to | |
// figure out what has changed between clients, kinda like a Merkle | |
// tree. It creates "buckets" that represent different time ranges, | |
// and divides time into smaller buckets the more recent they are. The |
This file contains 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'; | |
import lively from 'lively'; | |
// Global registry and resize handler | |
let _registeredInstances = []; | |
function register(inst) { | |
if (_registeredInstances.length === 0) { | |
window.addEventListener('resize', onResize); | |
} |
Tests are interesting, because you're trying to test code. But to write tests, you have to write code. Who tests the tests? For tests to be worth it you need to be sure that for each line of code you add, the value being added is more than the liability.
Value > Liability
Because belive me, tests are a liability. First, they are code that
This file contains 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
Could not cast value of type 'DetoxAppDelegateProxy' (0x10ffafed0) to 'Blink.AppDelegate' (0x10f998c20). | |
Signal caught: Abort trap: 6 | |
0 EarlGrey 0x0000000127e1d339 grey_signalHandler + 249 | |
1 libsystem_platform.dylib 0x0000000116826b3a _sigtramp + 26 | |
2 libsystem_kernel.dylib 0x00000001167ea430 libsystem_kernel.dylib + 1072 | |
3 libsystem_c.dylib 0x000000011659588f abort + 127 | |
4 libswiftCore.dylib 0x0000000115c4dd55 _ZN5swift10fatalErrorEjPKcz + 149 | |
5 libswiftCore.dylib 0x0000000115c2bdbb _ZN5swift24swift_dynamicCastFailureEPKvPKcS1_S3_S3_ + 75 | |
6 libswiftCore.dylib 0x0000000115c2be20 swift_dynamicCastClass + 0 | |
7 libswiftCore.dylib 0x0000000115c2bec0 swift_dynamicCastClassUnconditional + 80 |
NewerOlder