- Keep the preferred port with the project
- Each project need not run on port 3000 (Keep your
favicon.ico
from getting confused!) - Start up with
settings.json
in a conventional way - Install utils with your project, like spacejam, ESLint, etc..
- Have a uniform interface between package projects and meteor apps
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
// Option 1 | |
let var1, var2, var3; | |
if (someCondition) { | |
var1 = 'value1'; | |
var2 = 'value2'; | |
var3 = 'value3'; | |
} else { | |
var1 = "other1"; | |
var2 = "other2"; | |
var3 = "other3"; |
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 { | |
Keypair, | |
Transaction, | |
TransactionInstruction, | |
PublicKey, | |
Connection, | |
sendAndConfirmTransaction, | |
LAMPORTS_PER_SOL, | |
} = require("@solana/web3.js"); |
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
# git-auto-rebase | |
# git-auto-rebase --force-push | |
function git-auto-rebase() { | |
target="master" | |
if [[ $@ = "--force-push" ]] | |
then | |
push=true | |
else | |
push=false |
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, {useState, useEffect} from 'react'; | |
import {of, observable, interval} from 'rxjs'; | |
import {map} from 'rxjs/operators'; | |
import {ajax} from 'rxjs/ajax'; | |
import './App.css'; | |
const api = `https://randomuser.me/api/?results=5&seed=rx-react&nat=us&inc=name&noinfo`; | |
const getName = user => `${user.name.first} ${user.name.last}`; |
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
# some of the syntax requires Ruby 2.5+ | |
module Async | |
refine BasicObject do | |
def async(&block) | |
Async::Context.new(&block).run! | |
end | |
def enqueue(&block) | |
::Fiber.yield [:append, block] | |
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
// based on https://github.com/deanius/async-gen-vs-events/blob/3ad02c4af7ab7c56178e4614bb1585220ccec8db/walk_dir_tree_with_events.js | |
// three different algorithms on async, with a fake file system that's easy to modify | |
const { agent } = require("rx-helper"); | |
// Timer (useful for understanding how output gets processed) | |
const start = new Date() | |
const log = (whatevz) => console.log(new Date() - start, whatevz) | |
// Fake slow file system: |
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 eventStub = value => ({ | |
stopPropagation: () => {}, | |
preventDefault: () => {}, | |
persist: () => {}, | |
target: { | |
value, | |
checked: value, | |
}, | |
...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
// connect() is a function that injects Redux-related props into your component. | |
// You can inject data and callbacks that change that data by dispatching actions. | |
function connect(mapStateToProps, mapDispatchToProps) { | |
// It lets us inject component as the last step so people can use it as a decorator. | |
// Generally you don't need to worry about it. | |
return function (WrappedComponent) { | |
// It returns a component | |
return class extends React.Component { | |
render() { | |
return ( |
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
// Promise.all is good for executing many promises at once | |
Promise.all([ | |
promise1, | |
promise2 | |
]); | |
// Promise.resolve is good for wrapping synchronous code | |
Promise.resolve().then(function () { | |
if (somethingIsNotRight()) { | |
throw new Error("I will be rejected asynchronously!"); |
NewerOlder