Skip to content

Instantly share code, notes, and snippets.

View crazyboycjr's full-sized avatar
🎯
Focusing

Jingrong Chen crazyboycjr

🎯
Focusing
  • Duke University
  • Durham, NC
  • 17:51 (UTC -04:00)
View GitHub Profile
@merrymercy
merrymercy / jax_pjit_embedding.py
Created June 17, 2022 00:40
Use jax.pjit to partition embedding table
"""Test embedding table partition in XLA.
References:
- Introduction to pjit. https://jax.readthedocs.io/en/latest/jax-101/08-pjit.html
"""
from functools import partial
import jax
import jax.numpy as jnp
@danyangz
danyangz / client.cc
Created December 28, 2019 04:10
Asynchronous gRPC full-duplex streaming example
#include <chrono>
#include <fstream>
#include <grpc/grpc.h>
#include <grpcpp/grpcpp.h>
#include <grpcpp/resource_quota.h>
#include <grpcpp/support/channel_arguments.h>
#include <string>
#include <thread>
#include <unistd.h>
@VictorTaelin
VictorTaelin / promise_monad.md
Last active October 24, 2024 01:25
async/await is just the do-notation of the Promise monad

async/await is just the do-notation of the Promise monad

CertSimple just wrote a blog post arguing ES2017's async/await was the best thing to happen with JavaScript. I wholeheartedly agree.

In short, one of the (few?) good things about JavaScript used to be how well it handled asynchronous requests. This was mostly thanks to its Scheme-inherited implementation of functions and closures. That, though, was also one of its worst faults, because it led to the "callback hell", an seemingly unavoidable pattern that made highly asynchronous JS code almost unreadable. Many solutions attempted to solve that, but most failed. Promises almost did it, but failed too. Finally, async/await is here and, combined with Promises, it solves the problem for good. On this post, I'll explain why that is the case and trace a link between promises, async/await, the do-notation and monads.

First, let's illustrate the 3 styles by implementing

@romainl
romainl / colorscheme-override.md
Last active March 8, 2025 21:23
The right way to override any highlighting if you don't want to edit the colorscheme file directly

The right way to override any highlighting if you don't want to edit the colorscheme file directly

Generalities first

Suppose you have weird taste and you absolutely want:

  • your visual selection to always have a green background and black foreground,
  • your active statusline to always have a white background and red foreground,
  • your very own deep blue background.
@roadrunner2
roadrunner2 / 0 Linux-On-MBP-Late-2016.md
Last active May 19, 2025 18:08
Linux on MacBook Pro Late 2016 and Mid 2017 (with Touchbar)

Introduction

This is about documenting getting Linux running on the late 2016 and mid 2017 MPB's; the focus is mostly on the MacBookPro13,3 and MacBookPro14,3 (15inch models), but I try to make it relevant and provide information for MacBookPro13,1, MacBookPro13,2, MacBookPro14,1, and MacBookPro14,2 (13inch models) too. I'm currently using Fedora 27, but most the things should be valid for other recent distros even if the details differ. The kernel version is 4.14.x (after latest update).

The state of linux on the MBP (with particular focus on MacBookPro13,2) is also being tracked on https://github.com/Dunedan/mbp-2016-linux . And for Ubuntu users there are a couple tutorials (here and here) focused on that distro and the MacBook.

Note: For those who have followed these instructions ealier, and in particular for those who have had problems with the custom DSDT, modifying the DSDT is not necessary anymore - se

@djoreilly
djoreilly / ovs-cheat.md
Last active April 25, 2025 19:31
OVS cheat sheet

DB

ovs-vsctl list open_vswitch
ovs-vsctl list interface
ovs-vsctl list interface vxlan-ac000344
ovs-vsctl --columns=options list interface vxlan-ac000344
ovs-vsctl --columns=ofport,name list Interface
ovs-vsctl --columns=ofport,name --format=table list Interface
ovs-vsctl -f csv --no-heading --columns=_uuid list controller
ovs-vsctl -f csv --no-heading -d bare --columns=other_config list port
@muendelezaji
muendelezaji / bash-to-zsh-hist.py
Created October 5, 2016 14:18 — forked from op/bash-history-to-zsh-history.py
Convert Bash history to Zsh history
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This is how I used it:
# $ cat ~/.bash_history | python bash-to-zsh-hist.py >> ~/.zsh_history
import sys
import time
@ronchaine
ronchaine / arguments.hpp
Created May 26, 2016 00:37
Easier way to parse command line arguments with c++
#include <string>
#include <cstring>
#include <vector>
#include <unordered_map>
#include <tuple>
#include <iostream>
#include <iomanip>
@sarkian
sarkian / Road Rash (1994) (3DO) wine launcher. Fixes 'Could not find any CD-ROM drive' error.
Created August 10, 2014 15:29
Road Rash (1994) (3DO) wine launcher. Fixes 'Could not find any CD-ROM drive' error.
#!/bin/bash
# Road Rash (1994) (3DO) wine launcher
# Fixes 'Could not find any CD-ROM drive' error
# NOTE: ISO-image may be any valid ISO (e.g. Ubuntu Live-CD :))
# Default configuration (game and image placed in different directories)
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # path to directory with .iso (location of this script)
@splinterofchaos
splinterofchaos / monad-parser.cpp
Created November 19, 2012 17:32
Monadic parsing in C++
#include <memory>
#include <iostream>
#include <sstream>
#include <utility>
#include <algorithm>
#include <iterator>
struct sequence_tag {};
struct pointer_tag {};