Skip to content

Instantly share code, notes, and snippets.

View sumeet's full-sized avatar

Sumeet Agarwal sumeet

  • San Francisco, CA
View GitHub Profile
@sumeet
sumeet / playground.rs
Last active March 31, 2022 21:39 — forked from rust-play/playground.rs
Code shared from the Rust Playground
const SAMPLE_FLAT_LIST: &str = "(a b c d e f)";
const SAMPLE_NESTED_LIST: &str = "(a b c (d (e word-word) f))";
const SAMPLE_WORD: &str = "sample-word";
#[derive(Debug)]
enum Expr {
List(Vec<Expr>),
Word(String),
}
@sumeet
sumeet / hello_sdl2.c
Last active June 30, 2021 21:14 — forked from fschr/main.cpp
SDL2 Hello World
// SDL2 Hello, World!
// This should display a white screen for 2 seconds
// compile with: gcc -o hello_sdl2 -lSDL2 hello_sdl2.c
// run with: ./hello_sdl2
#include <SDL2/SDL.h>
#include <stdio.h>
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
@sumeet
sumeet / Undo.md
Created December 6, 2018 16:23 — forked from mlynch/Undo.md
Undo/Redo

Undo/Redo

Undo/Redo is one of those features of an application that you almost always need to have if you are building serious GUI tools for people to do work.

The best way to look at undo/redo is two stacks of operations the user has performed:

  • The Undo stack is the "history" of what they've done
  • The redo stack is the breadcrumbs back to the initial state before they started undoing
@sumeet
sumeet / playground.rs
Created December 3, 2018 07:13 — forked from rust-play/playground.rs
Code shared from the Rust Playground
struct Assignment {}
enum CodeNode {
Assignment(Assignment),
}
enum CodeNodeRef<'a> {
Assignment(&'a Assignment),
}
impl<'a> From<&'a Assignment> for CodeNodeRef<'a> {
fn from(x: &'a Assignment) -> Self {
CodeNodeRef::Assignment(x)
@sumeet
sumeet / playground.rs
Created October 3, 2018 20:41 — forked from rust-play/playground.rs
Code shared from the Rust Playground
#[derive(Debug)]
enum Bar {
A,
B
}
impl Bar {
fn as_ref(&self) -> Bar {
match self {
Bar::A => Bar::A,
# turns the display on and off using an external switch plugged into GPIO
# see http://razzpisampler.oreilly.com/ch07.html for more info
import RPi.GPIO as GPIO
import time
import os
# -- blacklight --
@sumeet
sumeet / redis_slowlog.rb
Last active August 6, 2017 10:14 — forked from joshuawscott/redis_slowlog.rb
Get Redis Slowlog Entries and parse them
require 'redis'
class Entry
attr_reader :log_number, :unix_timestamp, :microseconds, :command, :full_command
def initialize(raw_data)
@log_number = raw_data[0]
@unix_timestamp = raw_data[1]
@microseconds = raw_data[2]
@full_command = raw_data[4].join(' ')
end
@sumeet
sumeet / git-recent
Created September 6, 2016 20:57 — forked from jordan-brough/git-recent
Git: Display a list of recently checked out branches/tags/commits
#!/usr/bin/env bash
# Source: https://gist.github.com/jordan-brough/48e2803c0ffa6dc2e0bd
# Download this script as "git-recent" (no extension), chmod it to be executable and put it in your
# path somewhere (e.g. /usr/bin). You can then use it via `git recent` from inside any git repo.
# Example:
#
# $ git recent -n 5