Skip to content

Instantly share code, notes, and snippets.

View tictactoe.md

tictactoe

  • What is tic tac toe?
  • Build a data structure to represent the game board.
  • Write a function that updates the board with somebody's chosen position. Don't worry about detecting if somebody has won.
  • Write a function to detect that somebody has won.
  • What should the UI look like? Use excalidraw to mock up the layout of the page
  • Set up codesandbox.io with React and draw the board using the data structure we built earlier. Don't make it interactive, just draw the board.
  • Add a feature so that clicking on the board fills the spot.
  • Show a message when the game is over.
@luqmaan
luqmaan / algorithm_interview_study_notes.md
Last active October 2, 2020 02:10
I reviewed these notes before every interview
View algorithm_interview_study_notes.md

Algorithms notes

  • Implement binary search in js without recursion
  • implement quick sort in py and js
  • implement merge sort in js

for queues, you dequeue from 0 and enqueue at -1

View curry.js
function curry(func, ...argv) {
let prevArgs = argv;
function innerCurry(...args) {
prevArgs.push(...args)
if (prevArgs.length === func.length) {
return func(...prevArgs);
}
@luqmaan
luqmaan / generate-systemd-schedule.js
Last active May 26, 2020 08:10
Script from my blog post "Using systemd as a better cron." https://medium.com/horrible-hacks/using-systemd-as-a-better-cron-a4023eea996d. ⚠️ It may not actually work. 🤷‍♂️
View generate-systemd-schedule.js
const fs = require("fs");
const getTimerTemplate = (platform, importType, interval) => `
[Unit]
Description=Run ${platform}-${importType} every 15 minutes
Requires=${platform}-${importType}.service
[Timer]
Unit=${platform}-${importType}.service
OnUnitInactiveSec=${interval}
View hot-shots-with-promises.js
const StatsD = require("hot-shots");
const statsdclient = new StatsD();
const properties = Object.getOwnPropertyNames(
Object.getPrototypeOf(statsdclient)
);
const client = properties.reduce((prev, property) => {
if (property === "constructor") {
View gulptask.js
gulpTask = (name, fn) => {
done = (err) => {
if (err) {
console.log(`Completed task "${name}" with error`);
console.error(err)
}
else {
console.log(`Completed task "${name}" successfully`);
}
}
@luqmaan
luqmaan / string_to_dom.js
Last active April 12, 2017 18:38
Slightly interactive UI + templating with ES6. No handlebars, no react.
View string_to_dom.js
const stringToDom = (string) => document.createRange().createContextualFragment(string);
function viewTest(test) {
window.location.hash = test.id;
document.querySelector('#viewer').innerHTML = `
<iframe src="${test.link}"></iframe>
`;
}
fetch('/tests')
View parallel.js
export function* getMissingRates(orderNumbers, labelType) {
const ratesDeltaByOrderNumber = {};
const orderNumbersMissingRates = yield select(orderNumbersMissingRatesSelector, {orderNumbers, labelType});
if (!orderNumbersMissingRates.length) {
return;
}
yield put(startUpdatingRates(orderNumbersMissingRates, labelType));
View Redux Action Registry.md

Redux Action Registry

Create an object with all your action creators. This makes it easier to debug your application, since now you can dispatch actions from the console or from the Redux Devtools Extension.

Usage

ActionRegistry['data/accountBalance'].SET_ACCOUNT_BALANCE // "ordoro/data/accountBalance/SET_ACCOUNT_BALANCE"
ActionRegistry['data/accountBalance'].setAccountBalance(3) // {type: "ordoro/data/accountBalance/SET_ACCOUNT_BALANCE", payload: 3}
View gist:f2a61e63954c764c8fbe1acba33bcc9f
http://www.capmetro.org/metrolabs/
Open Data License Agreement and Terms of Use
Capital Metropolitan Transportation Authority (CMTA) hereby grants you (Licensee) non-exclusive, limited and revocable rights to use, reproduce, and redistribute CMTA Data (Data) hosted on the Socrata (http://www.socrata.com/) platform on data.texas.gov portal subject to the following Terms:
This data may include one or more of the following: CMTA Vehicle Location data, CMTA Service Alerts data, CMTA Trip Update Data, General Transit Feed Specification (“GTFS”) formatted data sets, Scheduled Service data, and Maps data.
CMTA trademarks and copyrighted materials, including any confusingly similar variants, may not be used in association with Data.
Data is provided on an "as is" and "as available" basis. CMTA makes no representations or warranties of any kind, express or implied. CMTA disclaims all warranties, express or implied, including but not limited to implied warranties of merchantability and fitness for a particular purpos