Skip to content

Instantly share code, notes, and snippets.

luqmaan /
Last active April 5, 2023 16:35
Write a python string to the clipboard via pbcopy (OS X)
def write_to_clipboard(output):
import subprocess
process = subprocess.Popen('pbcopy', env={'LANG': 'en_US.UTF-8'}, stdin=subprocess.PIPE)


  • 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 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 /
Last active October 2, 2020 02:10
I reviewed these notes before every interview

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

luqmaan / generate-systemd-schedule.js
Last active May 26, 2020 08:10
Script from my blog post "Using systemd as a better cron." ⚠️ It may not actually work. 🤷‍♂️
const fs = require("fs");
const getTimerTemplate = (platform, importType, interval) => `
Description=Run ${platform}-${importType} every 15 minutes
luqmaan / alterColor.js
Created November 29, 2012 14:38
Darkens or lightens a CSS RGB color.
* Darkens or lightens a CSS RGB color. Derived from
* @param {string} rgb "rgb(26,26,26)""
* @param {string} type "darken" or "lighten"
* @param {int} percent
* @return {string} returns the altered RGB color
function alterColor(rgb, type, percent) {
rgb = rgb.replace('rgb(', '').replace(')', '').split(',');
function curry(func, ...argv) {
let prevArgs = argv;
function innerCurry(...args) {
if (prevArgs.length === func.length) {
return func(...prevArgs);
luqmaan /
Last active February 13, 2018 04:22
CapMetro API Wishlist

Support CORS. Allow the API to be accessed through webapps without having to setup a proxy server in between.

Add documentation! Sneaking around the API and looking at the the trip planner code is not optimal.

Build an API the right way. Provide API keys so you can throttle requests and make sure things aren't getting slow.

More frequent polling of the bus locations. Right now it takes 30-90 seconds for bus locations to update. This sucks for users.

When will the 803 info be added to the GTFS database?

const StatsD = require("hot-shots");
const statsdclient = new StatsD();
const properties = Object.getOwnPropertyNames(
const client = properties.reduce((prev, property) => {
if (property === "constructor") {
luqmaan / debugging reselect
Last active July 17, 2017 23:32
debug reselect performance

Debugging reselect performance

Some steps I'm taking to debug bad performance with reselect.

My performance problems are coming from the fact that I am not using reselect properly. I wrote a bunch of selectors that use props but don't do anything to make sure they can be shared across multiple components.

The fix for this is:

But before rewriting tons of code, I'd like to see which selectors are recomputed the most.

gulpTask = (name, fn) => {
done = (err) => {
if (err) {
console.log(`Completed task "${name}" with error`);
else {
console.log(`Completed task "${name}" successfully`);