Skip to content

Instantly share code, notes, and snippets.

View dhruvio's full-sized avatar

Dhruv Dang dhruvio

View GitHub Profile
@dhruvio
dhruvio / index.js
Last active August 29, 2015 14:16
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Rebuild to run it on the right
var q = require("qwery"),
b = require("bonzo");
b(q("body")).html("hello");

Keybase proof

I hereby claim:

  • I am dhruvio on github.
  • I am dhruvio (https://keybase.io/dhruvio) on keybase.
  • I have a public key whose fingerprint is A0A5 1348 D0A8 85CF FB2E E0D1 148C 4058 1F4E CDA3

To claim this, I am signing this object:

@dhruvio
dhruvio / dokku-redis-container-inspect.json
Created January 19, 2016 02:39
dokku-redis-container-inspect.json
[
{
"Id": "3a19e0b8fd75356728abd16a7a44b67bebbc98efad1df719d6c8b6204f42df64",
"Created": "2016-01-14T07:30:45.986746602Z",
"Path": "/entrypoint.sh",
"Args": [
"redis-server"
],
"State": {
"Status": "running",
@dhruvio
dhruvio / bloc_technical_assessment.md
Last active August 17, 2016 06:25
bloc_technical_assessment

JavaScript

The bug you've encountered is a tricky one, and it has to do with something called Variable Scoping and Closures. This means that when you define a variable using var, it's important to understand where you can refer to its value, and when its value changes.

What's happening in your code is that the entire for loop is running to completion before any of the buttons are clicked. That means that by the time any of the buttons are clicked, the btnNum variable has a value of 3. Why 3? Because the loop increments btnNum to the first value that btnNum < prizes.length equates to false. So, even though you define the onclick handler each time the loop iterates with a different value for btnNum, the alert(...) statement only runs at the end of

# This isn't meant to be ran as a script, but line-by-line
# Props to Binary (benary.org) for helping me with this
# 0: Create a Scaleway instance and SSH into it
ssh root@...
# 1: Install Nix
adduser user # set a password, doesn't matter what because it's not staying long
adduser user sudo
su -l user
@dhruvio
dhruvio / RedBlackTree.hs
Created June 5, 2017 01:19 — forked from rampion/RedBlackTree.hs
red-black trees in haskell, using GADTs and Zippers
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneDeriving #-}
module RedBlackTree where
data Zero
data Succ n
type One = Succ Zero
data Black

Installing NixOS on the RockPi4 (B)

The general plan is to build an sd-image-aarch64 from nixpkgs/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix flash it to the eMMC and have the system come up, similar to how this “just works” for raspberry-pis.

The RockPi 4 is a RockChip RK3399 based board, build by radxa with the same formfactor as a rasperry Pi. One noticable difference is that the Rock Pi’s cpu is at the bottom to better allow for the

@dhruvio
dhruvio / nixos-install-hetzner-cloud.sh
Last active July 20, 2020 21:17 — forked from nh2/nixos-install-hetzner-cloud.sh
Script to install NixOS from the Hetzner Cloud NixOS bootable ISO image. Wipes the disk!
#! /usr/bin/env bash
# Script to install NixOS from the Hetzner Cloud NixOS bootable ISO image.
# Wipes the disk!
# Tested with Hetzner's `NixOS 20.03 (amd64/minimal)` ISO image.
#
# Run like:
#
# curl https://nh2.me/nixos-install-hetzner-cloud.sh | sudo bash
#
@dhruvio
dhruvio / coinmarketcap.gs
Created February 21, 2022 02:48
A script to get cryptocurrency price data from CoinMarketCap.
// Be sure to add your CoinMarketCap API key below.
function COINMARKETCAP(token) {
var requestOptions = {
method: 'GET',
qs: {
start: 1,
limit: 5000,
convert: 'USD'
},
headers: {
@dhruvio
dhruvio / CandleChartComponent.elm
Created April 4, 2022 19:53 — forked from NduatiK/CandleChartComponent.elm
Candle Chart with elm-charts
port module CandleStickComponent exposing (..)
import Browser
import Chart as C
import Chart.Attributes as CA exposing (dashed)
import Chart.Events as CE
import Chart.Item as CI
import Chart.Svg as CS
import Html as H exposing (Html, div, span, text)
import Html.Attributes exposing (class)