Skip to content

Instantly share code, notes, and snippets.

View ogwurujohnson's full-sized avatar
🪐
working on headless technologies

Johnson Ogwuru ogwurujohnson

🪐
working on headless technologies
View GitHub Profile
@ogwurujohnson
ogwurujohnson / useStateWithPromise.js
Created January 8, 2021 06:50
Await state changes, can be used as well to make a method call after state change
const useStateWithPromise = (initialState) => {
const [state, setState] = useState(initialState);
const resolverRef = useRef(null);
useEffect(() => {
if (resolverRef.current) {
resolverRef.current(state);
resolverRef.current = null;
}
/**
@ogwurujohnson
ogwurujohnson / BFS
Created February 12, 2020 14:00
A BFS algorithm i wrote for solving a proof of mine puzzle in a demo block chain i built
def bfs():
q = Queue()
q.enqueue([current_room["room_id"]])
visited = set()
while q.size() > 0:
path = q.dequeue()
v = path[-1]
if v not in visited:
if v == 182: ### change to whatever room you want to find
return path