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 / dragdrop.rs
Created May 23, 2021 19:04
egui dragdrop probe
use eframe::egui::*;
use std::hash::Hash;
struct DragDropContext<S: DragDropSource> {
dragged_source: Option<S>,
}
impl<S: DragDropSource> DragDropContext<S> {
fn new() -> Self {
Self {
from math import sqrt
import functools
import json
NORD_COLORS = """\
#2E3440
#3B4252
#434C5E
#4C566A
#8FBCBB
@sumeet
sumeet / day18a.rb
Last active December 18, 2020 07:05
day 18 2020 ruby
class Integer
def -(other)
self * other
end
end
p input.gsub("*", "-").lines.map(&method(:eval)).sum
typedef UUID = u128
typedef type_t = Free { id: UUID } | Resolved { id: UUID, params: Vec<type_t> }
input relation TypeEquality(type_a: type_t, type_b: type_t)
output relation Resolution(free_var_id: UUID, typ: type_t)
////////////////////
// direct relations/
////////////////////
Resolution(free_var_id, typ) :-
start;
insert TypeEquality(Resolved{1, [Free{2}]},
Resolved{1, [Resolved{2, []}]});
# this should imply Free{2} == Resolved{2, []}
commit;
dump Resolution;
@sumeet
sumeet / sumbridge.rb
Created October 11, 2020 00:46
another masterpiece, idiomatic ruby converting one test type to another
def describe(name, &block)
klass = Class.new(Bridge, &block)
Object.const_set(name + "Test", klass)
end
class Bridge < Minitest::Test
def self.before(range, &block)
define_method("before_#{range}") do |*args|
instance_eval(&block)
super *args
impl InsertLiteralOptionGenerator {
fn generate_options_for_return_type(&self,
search_params: &CodeSearchParams,
env_genie: &EnvGenie,
options: &mut Vec<InsertCodeMenuOption>,
input_str: &String,
return_type: &lang::Type) {
if return_type.matches_spec(&lang::STRING_TYPESPEC) {
options.push(self.string_literal_option(input_str.clone()));
} else if return_type.matches_spec(&lang::NULL_TYPESPEC) {

EOrr SEP 21, 2015

source

hmmm, allow me to play devils advocate… I think this is great and it is important for a subset of technologists, but from a fundamental perspective the command line interface is an inefficient hack necessitated by the limited ways of getting things accomplished.

There is always a tradeoff between universal utility and specialized economy of interactions. Deep knowledge of command line syntax and functionality allows a user a much greater ability to accomplish various tasks. Yet this ignores the opportunity cost of acquiring knowledge necessary to become an expert in any interface over acquiring higher level knowledge.

A basic level of proficiency of any underlying process is necessary to be an expert in any field. Yet more abstracted forms of interaction allows one to devote more time to building upon what has come before.There is always a need for experts at every level of knowledge to furth

import json
import subprocess
class Bspwm:
@classmethod
def monitors(cls):
monitor_names = cls._query_monitor_names()
return [cls._query_monitor(name) for name in monitor_names]
@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