Skip to content

Instantly share code, notes, and snippets.

View jm96441n's full-sized avatar

John Maguire jm96441n

View GitHub Profile
{
"name": "green-foxes-todo",
"version": "1.0.0",
"description": "This is the reddit green foxes todo web project.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "gulp",
"start": "node app.js"
},
def each(array)
i = 0
while i < array.length
yield(array[i])
i += 1
end
end
def find(array)
each(array) {|element| return element if yield(element)}
def largestEvenSum(self, nums: List[int], k: int) -> int:
if k > len(nums):
return -1
evens = [-n for n in nums if n % 2 == 0]
odds = [-n for n in nums if n % 2 == 1]
heapq.heapify(evens)
heapq.heapify(odds)
if k == 1:
return -(evens[0]) if len(evens) > 0 else -1
sum = 0
class TimeMap:
def __init__(self):
self._tm: dict[str, dict[int, str]] = {}
self._stamps: dict[str, list[int]] = defaultdict(list)
def set(self, key: str, value: str, timestamp: int) -> None:
self._stamps[key].append(timestamp)
if key not in self._tm:
self._tm[key] = {}
self._tm[key][timestamp] = value
@jm96441n
jm96441n / consul-values.yml
Created January 20, 2023 17:52
Test Proxy Log Command
global:
name: consul
datacenter: dc1
tls:
enabled: false
connectInject:
enabled: true
controller:
enabled: true
server:
@jm96441n
jm96441n / bootstrap-token.yaml
Created February 10, 2023 02:38
Test cross namespace api-gateway bug
apiVersion: v1
data:
token: NjFmNjlhMjctMDI4ZC1hZDc2LWU0ZTUtYjUzODMzNGNhZjNl
kind: Secret
metadata:
labels:
managed-by: consul-k8s
name: nsbug-apigw-consul-bootstrap-acl-token
namespace: consul
type: Opaque
@jm96441n
jm96441n / 207.py
Created July 18, 2023 15:44
toposort
from __future__ import annotations
from collections import defaultdict, deque
from dataclasses import dataclass
from typing import Any, Dict, List, Optional, Set # noqa
import ipdb # type: ignore
class Node:
#! /usr/bin/zsh
dir=$1
sess=grind3
mkdir ./$sess/$dir
cd ./$sess/$dir
touch __init__.py
touch main.py
echo 'from dataclasses import dataclass
@jm96441n
jm96441n / main.py
Created August 7, 2023 19:26
RPN calculator
import math
from dataclasses import dataclass
from typing import Any, List, Optional # noqa
import ipdb # type: ignore
class Solution:
functions = {
"+": (lambda x, y: x + y),
@jm96441n
jm96441n / cluster.yaml
Created April 17, 2024 19:26
NET-8412 replication
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: basic
nodes:
- role: control-plane
image: kindest/node:v1.25.3
- role: worker
image: kindest/node:v1.25.3