Skip to content

Instantly share code, notes, and snippets.

View ShreckYe's full-sized avatar

Yongshun Shreck Ye ShreckYe

View GitHub Profile
@ice1000
ice1000 / MHLLeanTIZAgdaCompetition.agda
Created February 5, 2021 16:46
Implementing a lean example in Agda
{- Lean 4
open list
#eval filter (= 4) [1, 2, 4]
-}
open import Data.Nat renaming (ℕ to Nat; _≟_ to decEqNat)
open import Data.List using (List; []; _∷_)
open import Data.Bool using (true; false)
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
@scmx
scmx / git-commit-title-first-word.md
Last active June 11, 2025 04:49
Example list of verbs / first word to use in git commit title #git #commit #title

Example list of first words to use in a git commit title

I like writing well-formed git commits that explain the intention behind why a code change was made.

Check out Chris Beams excellent How to Write a Git Commit Message if you haven't read it.

Anyway, for a project I've been working on I've gathered up 900+ commits that hold up a pretty high quality (except for one 😁). Let's look at some trends about these commits!

Most common first words in commit titles of a project

@guss77
guss77 / VertxBufferOutputStream.java
Created September 20, 2018 12:32
An output stream implementation over a Vert.x `Buffer` instance - like `ByteArrayOutputStream` but a bit Vert.xified.
import java.io.IOException;
import java.io.OutputStream;
import io.vertx.core.buffer.Buffer;
public class VertxBufferOutputStream extends OutputStream {
private Buffer buffer;
public BufferOutputStream() {
this.buffer = Buffer.buffer();
@gaearon
gaearon / modern_js.md
Last active April 14, 2025 19:22
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
@brendanzab
brendanzab / CuTT.md
Last active September 19, 2023 10:23 — forked from AndyShiue/CuTT.md
Cubical type theory for dummies

I think I’ve figured out most parts of the cubical type theory paper(s); I’m going to take a shot to explain it informally in the format of Q&As. I prefer using syntax or terminologies that fit better rather than the more standard ones.

Q: What is cubical type theory? A: It’s a type theory giving homotopy type theory its computational meaning.

Q: What is homotopy type theory then? A: It’s traditional type theory (which refers to Martin-Löf type theory in this Q&A) augmented with higher inductive types and the univalence axiom.

Q: So what are HIT and UA? A: A HIT is a type equipped with custom equality, as an example, you can write a type similar to the natural numbers but with an equality between all even numbers. Well, it cannot be called natural numbers then.

@jhrr
jhrr / russell.agda
Created March 24, 2015 14:46
Russell's paradox in Agda
{-# OPTIONS --type-in-type #-}
{-
Computer Aided Formal Reasoning (G53CFR, G54CFR)
Thorsten Altenkirch
Lecture 20: Russell's paradox
In this lecture we show that it is inconsistent to have
Set:Set. Luckily, Agda is aware of this and indeed
Set=Set₀ : Set₁ : Set₂ : ...
@msrose
msrose / combining-git-repositories.md
Last active July 7, 2025 08:40
How to combine two git repositories.

Combining two git repositories

Use case: You have repository A with remote location rA, and repository B (which may or may not have remote location rB). You want to do one of two things:

  • preserve all commits of both repositories, but replace everything from A with the contents of B, and use rA as your remote location
  • actually combine the two repositories, as if they are two branches that you want to merge, using rA as the remote location

NB: Check out git subtree/git submodule and this Stack Overflow question before going through the steps below. This gist is just a record of how I solved this problem on my own one day.

Before starting, make sure your local and remote repositories are up-to-date with all changes you need. The following steps use the general idea of changing the remote origin and renaming the local master branch of one of the repos in order to combine the two master branches.

@biswarupadhikari
biswarupadhikari / gist:4038614
Created November 8, 2012 12:50
How to Detect Right Click Linux Java JTable
jt.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent e) {
int r = jt.rowAtPoint(e.getPoint());
if (r >= 0 && r < jt.getRowCount()) {
jt.setRowSelectionInterval(r, r);
} else {
jt.clearSelection();
}
int rowindex = jt.getSelectedRow();