Skip to content

Instantly share code, notes, and snippets.

@nrubin29
nrubin29 / homebrew_m1.sh
Last active November 24, 2023 11:27
Install Native Homebrew on Apple Silicon M1
# We'll be installing Homebrew in the /opt directory.
cd /opt
# Create a directory for Homebrew. This requires root permissions.
sudo mkdir homebrew
# Make us the owner of the directory so that we no longer require root permissions.
sudo chown -R $(whoami) /opt/homebrew
# Download and unzip Homebrew. This command can be found at https://docs.brew.sh/Installation.
@nrubin29
nrubin29 / balanced_parentheses_one_line.py
Last active April 9, 2021 11:37
The classic balanced parentheses algorithm implemented in one line (one expression) in Python for this video: https://youtu.be/0eeweCiUU4U
print(
(
lambda expr, stack: all(
len(stack) == 0 if char is None else
stack.append(char) or True if char in '([{' else
len(stack) > 0 and {'(': ')', '[': ']', '{': '}'}[stack.pop()] == char if char in ')]}' else
True
for char in expr
)
)(
@nrubin29
nrubin29 / DataStore.swift
Last active October 15, 2017 21:14
A small Swift library that provides a persistent data store using NSCoding.
//
// DataStore.swift
// A persistent key-value store.
//
// Created by Noah Rubin on 6/29/16.
// Copyright © 2016 nrubin29. All rights reserved.
//
import Foundation
@nrubin29
nrubin29 / ObjectLib.java
Last active June 24, 2016 17:16
ObjectLib
import java.awt.Rectangle;
class Entity {
private int x, y, w, h;
public Entity(int x, int y, int w, int h) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
//setting up
boolean[][] bricks = new boolean[14][10];
float bx, by, bdiameter, bxspeed, byspeed;
int paddleX, speed;
boolean right, left;
int lives, score;
void setup() {
size(500, 450);
@nrubin29
nrubin29 / ProjectileLib.java
Last active June 24, 2016 13:16
ProjectileLib
import java.awt.Rectangle;
class Entity {
private int x, y, w, h, xSpeed, ySpeed;
public Entity(int x, int y, int w, int h, int xSpeed, int ySpeed) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
@nrubin29
nrubin29 / minglish_lesson.py
Created May 26, 2016 15:25
minglish_lesson solution
def answer(words):
# first, we need to generate the graph
vertices = []
letters = list(set([val for sublist in [list(word) for word in words] for val in sublist]))
for word in words:
for letter in list(word):
letters.append(letter)
for i in range(len(words) - 1):
@nrubin29
nrubin29 / Node.java
Last active April 16, 2020 04:20
Sum Problem
package me.nrubin29.sumproblem;
import java.util.ArrayList;
public class Node implements Comparable<Node> {
private int value;
private ArrayList<NodePair> children;
public Node(int value) {
package me.pogostick29.infirmary;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;