Skip to content

Instantly share code, notes, and snippets.

View deanrad's full-sized avatar
🎯
Staying On Target

Dean Radcliffe deanrad

🎯
Staying On Target
View GitHub Profile
@webbower
webbower / multi-var-set.js
Created July 2, 2021 17:16
HTML/CSS/JS Patterns
// Option 1
let var1, var2, var3;
if (someCondition) {
var1 = 'value1';
var2 = 'value2';
var3 = 'value3';
} else {
var1 = "other1";
var2 = "other2";
var3 = "other3";
@fukaoi
fukaoi / memo-exmaple.js
Last active July 24, 2022 22:54
solana-program-library-memo
const {
Keypair,
Transaction,
TransactionInstruction,
PublicKey,
Connection,
sendAndConfirmTransaction,
LAMPORTS_PER_SOL,
} = require("@solana/web3.js");
# git-auto-rebase
# git-auto-rebase --force-push
function git-auto-rebase() {
target="master"
if [[ $@ = "--force-push" ]]
then
push=true
else
push=false
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}`;
@JoshCheek
JoshCheek / async_ruby.rb
Created March 6, 2019 04:48
Asynchronous Ruby
# 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
@JoshCheek
JoshCheek / observer_async_options.js
Last active March 6, 2019 14:54
Three variations on async
// 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:
const eventStub = value => ({
stopPropagation: () => {},
preventDefault: () => {},
persist: () => {},
target: {
value,
checked: value,
},
...value,
});
@gaearon
gaearon / connect.js
Last active April 11, 2024 06:46
connect.js explained
// 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 (
@deanrad
deanrad / _README.md
Last active August 29, 2015 14:27
Meteor package.json for fun and profit

Why use pacakge.json with Meteor ?

  • 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

How to use it ?

@nolanlawson
nolanlawson / protips.js
Last active February 4, 2024 18:06
Promise protips - stuff I wish I had known when I started with Promises
// 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!");