Skip to content

Instantly share code, notes, and snippets.

View nischalshrestha's full-sized avatar
🔨

Nischal Shrestha nischalshrestha

🔨
View GitHub Profile
---
title: "Intro to Grammar of Graphics"
subtitle: "seaborn vs plotnine"
author: "Credit to @ChelseaParlett"
jupyter: venv-prez-kernel
format:
revealjs:
height: 1400
width: 1920
execute:
@manualbashing
manualbashing / blog.md
Last active December 10, 2022 17:50
Build a drum grid with emojis in #SonicPi

The other day I was going through one of MrBomb's awesome SonicPi tutorials, where he used a nifty trick with arrays to build a drum grid similar to this one: https://learningmusic.ableton.com/make-beats/make-beats.html

This already worked perfectly, but I thought it could be taken one step further by building the arrays from strings of emojis:

use_bpm 98

open_hat   = "⬜⬜❎⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜".split("")
closed_hat = "❎❎⬜⬜❎⬜❎⬜❎⬜❎⬜❎⬜❎⬜".split("")
clap = "⬜⬜⬜⬜❎⬜⬜⬜⬜⬜⬜⬜❎⬜⬜⬜".split("")
@chendaniely
chendaniely / altair_test.Rmd
Last active December 4, 2020 17:03
Altair in Rmd
---
title: "rmd altair"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(reticulate)
@MichaelCurrin
MichaelCurrin / README.md
Last active April 14, 2024 16:26
GitHub GraphQL - Get Pull Requests using GH's GraphQL API

Get Pull Requests using GH's GraphQL API

How to get Pull Requests data using Github in the browser, or using the API to allow for automating reporting or building in values into a website.

Resources

@jarmitage
jarmitage / avril.tidal
Created April 14, 2020 20:37
Avril 14th
-- happy avril 14th :)))))))))))))))))))))))))))))))))))))))
do
let bars = 4
key = "8"
righthand = "[[4 -3] [0 _ _ _ _ _ 0]] [[-3, -8] [7 5 4 0]]"
lefthand = "[0 9 12 16] [4 12 16 19] [5 12 17 19] [2 12 17 16]"
d1 $ slow bars
$ stack [
n (righthand + key + "<24 36>/2"),
@rich-iannone
rich-iannone / gist:1da1ae7a7203958a0c5b1bd1d4b24017
Last active October 13, 2021 03:51
This gt code allows you to make a summary table based on the `pizzaplace` dataset.
library(tidyverse)
library(paletteer)
library(gt)
pizzaplace %>%
mutate(type = case_when(
type == "chicken" ~ "chicken (pizzas with chicken as a major ingredient)",
type == "classic" ~ "classic (classical pizzas)",
type == "supreme" ~ "supreme (pizzas that try a little harder)",
type == "veggie" ~ "veggie (pizzas without any meats whatsoever)",
@jennybc
jennybc / 2020-03-29_sane-legend.R
Created March 30, 2020 05:21
Make the legend order = data order, with forcats::fct_reorder2()
library(tidyverse)
library(patchwork)
dat_wide <- tibble(
x = 1:3,
top = c(4.5, 4, 5.5),
middle = c(4, 4.75, 5),
bottom = c(3.5, 3.75, 4.5)
)
# What's the most natural way to express this code in base R?
library(dplyr, warn.conflicts = FALSE)
mtcars %>%
group_by(cyl) %>%
summarise(mean = mean(disp), n = n())
#> # A tibble: 3 x 3
#> cyl mean n
#> <dbl> <dbl> <int>
#> 1 4 105. 11
#> 2 6 183. 7

Introduction

I was recently asked to explain why I felt disappointed by Haskell, as a language. And, well. Crucified for crucified, I might as well criticise Haskell publicly.

First though, I need to make it explicit that I claim no particular skill with the language - I will in fact vehemently (and convincingly!) argue that I'm a terrible Haskell programmer. And what I'm about to explain is not meant as The Truth, but my current understanding, potentially flawed, incomplete, or flat out incorrect. I welcome any attempt at proving me wrong, because when I dislike something that so many clever people worship, it's usually because I missed an important detail.

Another important point is that this is not meant to convey the idea that Haskell is a bad language. I do feel, however, that the vocal, and sometimes aggressive, reverence in which it's held might lead people to have unreasonable expectations. It certainly was my case, and the reason I'm writing this.

Type classes

I love the concept of type class

@munificent
munificent / generate.c
Last active May 1, 2024 20:06
A random dungeon generator that fits on a business card
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#define r return // 2008-2019
#define l(a, b, c, d) for (i y=a;y\
<b; y++) for (int x = c; x < d; x++)
typedef int i;const i H=40;const i W
=80;i m[40][80];i g(i x){r rand()%x;
}void cave(i s){i w=g(10)+5;i h=g(6)
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u