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
// These assertions don't work, from https://github.com/mobxjs/mobx-state-tree/blob/master/__tests__/core/type-system.test.ts. Fails with TS 4.3 and greater. https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-3.html | |
test("maybe / optional type inference verification", () => { | |
const T = types.model({ | |
a: types.string, | |
b: "test", | |
c: types.maybe(types.string), | |
d: types.maybeNull(types.string), | |
e: types.optional(types.string, "test") | |
}) |
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 { | |
StyleSheet, | |
Text as RNText, | |
TextProps as RNTextProps, | |
TextStyle, | |
} from 'react-native'; | |
const styles = StyleSheet.create({ | |
header: { |
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
#!/usr/bin/env node | |
/** | |
* If you put this program in your PATH, you can use it like this: | |
* | |
* ask "What is the meaning of life?" | |
* | |
* or | |
* | |
* ask my_file.md |
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 { makeAutoObservable, makeObservable, observable } from "mobx"; | |
import { DataModel, Model, model, prop } from "mobx-keystone"; | |
import { types } from "mobx-state-tree"; | |
function bench(f: () => { value: number }) { | |
// Warmup | |
let sum = 0; | |
for (let index = 0; index < 100_000; ++index) { | |
sum += f().value; | |
} |
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> | |
<head> | |
<link rel="stylesheet" type="text/css" href="css/app.css"> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title></title> |
- Get a GitHub account
- Sign up for Netlify with your GitHub account
- Download and install Visual Studio Code
- Download and install Node.js
- Install git:
- Mac OSX: Using the terminal, Install Homebrew and then install Git
- Windows: Download and install Git for Windows
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
class SampleObject < ApplicationRecord | |
def external_components | |
Rails.cache.fetch("#{cache_key_with_version}/components", expires_in: 12.hours) do | |
# Some long running task that fetches "components" | |
end | |
end | |
end |
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
doSomeLongRunningTask(function(response, error) { | |
// This function is running as a CALLBACK inside the long task | |
// So it logs on completion | |
console.log(response) | |
// Return the response | |
return response; | |
} | |
var res = doSomeLongRunningTask(function(response, error) { |
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
# Use RSpec for testing https://rspec.info/ | |
require 'rspec' | |
# Define the flatten function, we'll use it recursively | |
# On the initial run, set `results` to an empty array | |
def flatten(array, results = []) | |
# Check that array is not nil | |
if array | |
# For each item in the array, check if it's a nested array | |
array.each do |item| |
NewerOlder