home    login

Adnan's adventure (b)log

I'm on twitter, my projects are on github. This (b)log is running on mikro.

July, 2023
April, 2023
October, 2022
June, 2022
May, 2022
April, 2022
March, 2022
February, 2022
January, 2022
November, 2021

The Design Of Everyday Things

September, 2021
August, 2021
June, 2021

Get Corsair Esperanza EG106 gamepad working on Linux

Device is recognized as Bus 001 Device 018: ID 045e:028e Microsoft Corp. Xbox360 Controller but no inputs are registered.

It seems that the generic gamepad driver doesn't properly initialize the device, so this script sends the proper initialization commands to the joystick:

#!/usr/bin/env python3

import os
import sys

    import usb.core
    import usb.util
except ImportError:
    print("First, install the pyusb module with PIP or your package manager.")
    if os.geteuid() != 0:
        print("You need to run this script with sudo")

    dev = usb.core.find(find_all=True)

    for d in dev:
        if d.idVendor == 0x045e and d.idProduct == 0x028e:
            d.ctrl_transfer(0xc1, 0x01, 0x0100, 0x00, 0x14)


May, 2021
April, 2021
March, 2021
February, 2021
January, 2021
December, 2020
October, 2020
September, 2020
August, 2020
June, 2020
May, 2020
April, 2020
March, 2020
February, 2020
January, 2020
December, 2019
November, 2019
October, 2019
September, 2019
August, 2019
July, 2019
June, 2019
May, 2019
April, 2019
March, 2019
February, 2019
January, 2019
December, 2018
November, 2018
October, 2018
September, 2018
August, 2018
July, 2018
June, 2018
May, 2018
April, 2018

MySQL query to CSV

mysql dbname -uuser -ppassword -h "host" -e 'query' | sed "s/'/\'/;s/\t/\",\"/g;s/^/\"/;s/$/\"/;s/\n//g" > file.csv

January, 2018
December, 2017
November, 2017
October, 2017
September, 2017
August, 2017
44. Eric Peters // Coffee Commissary // Los Angeles

Flavor notes
“Syrupy, Jammy, Heavy Body, Espresso-like”

Suggested Coffee
“A natural processed Colombian Coffee”

Brew Style: Inverted
Coffee: 22 grams
Grind Size: Setting 2 on Handground
Water: 100 grams at 190F
Water-to-Coffee Ratio: 5:1
Brew Time: 1:30

50g bloom for 50 seconds 
Agitate the grounds using a bar spoon 
10 second pour to 100g 
10 second rest 
20 second plunge


43. Brandon // Handground

Flavor notes
“Brings out the juiciest flavors in the coffee. Thick, full-bodied, espresso-like”

Suggested Coffee
“Natural processed Colombian coffees”

Brew Style: Inverted
Coffee: 30 grams
Grind Size: Setting 5.5 on Handground
Water: 120 grams at 184F
Water-to-Coffee Ratio: 4:1
Brew Time: 1:10

Pour 120g of water, stir for 10 seconds
Immediately put cap on and flip on top of cup
Pull plunger slightly to stop coffee from dripping (creates vacuum) 
Wait 40 seconds, press for 20 seconds. 
July, 2017
June, 2017
May, 2017
April, 2017
March, 2017
February, 2017
January, 2017
December, 2016

Why we need style guides

Let's say you start an e-commerce site.

Your first engineer is Picasso during his blue period. Your codebase quickly becomes filled with Picasso blue period javascript files. He paints you a javascript shopping cart without a problem. He's done it a million times before. But this is his best one. It's his masterpiece. And very blue.

Your second engineer is Salvador Dali. He shows up on his first day with a camera, a single paintbrush, a silly mustache, and starts contributing some crazy surrealist javascript files.

This influences Picasso as they work together and Picasso starts switching things up and begins adding cubism files to the codebase. The codebase is so new that Picasso and Dali can continue adding new files at any time with no harm, because there is no maintenance when it's just two engineers adding new functionality. No one is stepping on each other's toes. There's enough paint for everyone.

Then you hire Monet and he comes in and leaves his impression on everything.

Now you have a blue period shopping cart, impressionist image lazy loading, surrealist photo slide show, and cubism style event tracking in /app/assets/javascripts. The javascripts folder becomes a museum.

Let's jump to the future 4 years later. Lots of major functionality has already been built. Picasso has left the company to pursue a company built on a guernica style. Your business focus has shifted a bit and you need someone to extend Picasso's blue period shopping cart to support collaborative shopping (lots of people sharing the same cart in realtime).

Luckily you just hired a rising star in javascript land that likes to spray paint things on the wall, his name is Banksy. So you tell Banksy, "Hey for your first job we need you to modify our shopping cart so it supports collaboration. Timing is really important for the big relaunch, fortunately this should be really easy because we already have Picasso's shopping cart and it's already a masterpiece. Just reuse that."

So Banksy goes in and spray paints over your Picasso shopping cart and makes it collaborative and you have a big successful relaunch.

A month later a bug report comes in about removing items from the shopping cart. Banksy is busy on another project, so you get Monet to go in and fix it.

Monet doesn't know how to use spray paint cans. So his attempts to fix it are sloppy. He breaks the build. He switches back to the brush and just paints over it, but it took a lot longer than it should have because of the time to understand and adopt an unfamiliar style.

When you have over 80 engineers contributing to one codebase, you quickly learn your usual ways of doing things don't work. So we try to turn everyone into Picasso. No matter where you jump in to the codebase, all the files are familiar and look like they were painted by you.

The most important thing, no matter what your preferred javascript style is, is to be consistent when working with a team or a large codebase that will have to be maintained in the future.

The style that works best for our team is our Picasso style since that's how it all started.

We open sourced our style guide so other teams could fork it and turn it into a Monet style guide or a Banksy style guide. Which is lots of fun to watch.

As an individual painter/engineer working on side projects and exploring all the wonderful things you can do with javascript, please throw conventions away and ignore everything anyone has ever said.

It's the only way the world will enjoy the next Picasso.

~ Harrison Shoff

November, 2016

JS Library Batch #1

  • dat.gui.js - A lightweight graphical user interface for changing variables in JavaScript.
  • is.js - Micro check library.
  • messenger.js - Growl-style alerts and messages for your app.
  • Chosen - Chosen is a library for making long, unwieldy select boxes more friendly.
October, 2016

"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects."

-- Robert Heinlein

September, 2016
August, 2016

Added AI players to my simple multiplayer game, check it out at http://pixelwars.hajdarevic.net


What Golang Is and Is Not

Go is an engineering tool, in a much broader sense. To appreciate it properly I think you have to have spent a decent amount of time responsible for the full lifecycle. If all you ever do is write and commit code then much of Go will be lost on you.

July, 2016

I've built a simple multiplayer game with socket.io, crafty.js & node.js. Check it out

June, 2016
May, 2016

IDE script for JetBrains IDEs that enables you to start multiple configurations in debug mode at once.

Go to Tools->IDE Scripting Console, select Groovy as language of choice and paste the code provided. You have to select all lines and press CTRL+ENTER to run the script.

Some people won't have IDE scripting option visible in the menus so you'll have to create manual keystroke binding to open it. Just make sure that you replace configuration names with your own :-)

multiRun = [
  "IRB console: [local] document_storage_service",
  "IRB console: [local] metadata_service",
  "IRB console: [local] table_storage_service",

allSettings = com.intellij.execution.RunManager.getInstance(com.intellij.openapi.project.ProjectManager.getInstance().getOpenProjects()[0]).getAllSettings();
executor = com.intellij.execution.ExecutorRegistry.getInstance().getExecutorById(com.intellij.openapi.wm.ToolWindowId.DEBUG);

toBeRun = allSettings.findAll { setting ->
  multiRun.any { setting.toString() == it }
}.each {
    com.intellij.execution.runners.ExecutionUtil.runConfiguration(it, executor);

Great concept! sshd port using TOTP


Phrack is back!


Push button power switch with the ability of microcontroller to turn itself off.


How they do deployment at StackOverflow (2016 edition)

April, 2016

So you want to validate an email field that conforms to the RFC822? Here's a "simple" regex for that ;-)


If your Nokia Lumia 920 suddenly starts opening camera app, and the battery starts to drain real quick (i.e. it can't last for more than four-five hours in idle mode) it's the Side Volume Power Camera Switch Button Flex Cable which has malfunctioned. Try replacing it first before buying a new battery... It could save you ~30$


FlexboxPatterns.com - cool resource for some common web page elements done using flexbox.


Lesson we tend to forget from time to time.


Some tips on working with large CSV files in Ruby.

March, 2016

Color Brewer 2 is a really good resource for selecting map color palettes. Their published paper goes a little bit more in detail on why selecting effective color schemes for thematic maps is surprisingly difficult.


Everybody is writing their own databases nowadays.


I have never seen more poetic and in depth comparison of cheaper items.


Cloud design patterns - Microsoft Developer Network


transfer.sh - easy file sharing from the command line


Good post (or perhaps an essay?) on How to Deploy Software