Skip to content

Instantly share code, notes, and snippets.

View maxim's full-sized avatar
🛠️

Max Chernyak maxim

🛠️
View GitHub Profile
@maxim
maxim / msteams-new.lsrules
Last active April 24, 2024 00:02
Little Snitch rules for Microsoft Teams, updated at 2024-04-24 00:02:01+00:00.
{
"description": "Rules based on Microsoft Endpoints at https://endpoints.office.com/endpoints/worldwide?clientrequestid=b794baa0-662f-4592-b4f0-46ab3284b612&ServiceAreas=Skype",
"name": "Microsoft Teams",
"rules": [
{
"action": "allow",
"process": "/Applications/Microsoft Teams (work or school).app/Contents/MacOS/MSTeams",
"remote-addresses": "13.107.64.0-13.107.127.255,52.112.0.0-52.115.255.255,52.122.0.0-52.123.255.255,2603:1063::-2603:1063:3ff:ffff:ffff:ffff:ffff:ffff",
"ports": "3478-3481",
"protocol": "udp"
require 'minitest/mock'
module StubStrict
module_function
def render_parameters(ruby_parameters)
ruby_parameters.map { |type, name|
case type
when :req; name.to_s
when :opt; "#{name} = 'value'"
#!/usr/bin/env bash
set -e
# Usage:
# ./install-rclone.sh v1.65.0-beta.7390.2a30c417a.fix-b2-upload-url
# Check if the argument is supplied
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <rclone_version>"
exit 1
@maxim
maxim / options.rb
Last active September 17, 2023 04:38
option :foo_a
option :foo_b, value: {type: Integer}
option :bar_x, value: {type: String}
option :bar_y
option :bar_z, value: {type: Integer}
attr_reader :kwargs
def self.from_options(options)
class Severity
include Comparable
attr_reader :value
ORDER = %i[low medium high]
def self.[](value)
new(value)
end
def initialize(value)
@maxim
maxim / bench.rb
Last active May 13, 2023 12:17
Catch throw vs raise rescue vs baseline return (Ruby v3.2.0)
code1 = -> { catch(:foo) { throw(:foo, 'string') } }
code2 = -> { begin; raise RuntimeError; rescue RuntimeError; 'string' end }
code3 = -> { 'string' }
Benchmark.ips do |x|
x.report("catch a throw") {
value = code1.call
}
x.report("rescue and exception") {
@maxim
maxim / skype.lsrules
Last active April 24, 2024 00:02
Little Snitch rules for Skype, updated at 2024-04-24 00:02:01+00:00.
{
"description": "Rules based on Skype FAQ at https://support.skype.com/en/faq/FA148/which-ports-need-to-be-open-to-use-skype-on-desktop",
"name": "Skype",
"rules": [
{
"action": "allow",
"process": "/Applications/Skype.app/Contents/MacOS/Skype",
"ports": "443,1000-10000,50000-65000,16000-26000",
"protocol": "TCP"
},
@maxim
maxim / msteams.lsrules
Last active April 24, 2024 00:02
Little Snitch rules for Microsoft Teams classic, updated at 2024-04-24 00:02:01+00:00.
{
"description": "Rules based on Microsoft Endpoints at https://endpoints.office.com/endpoints/worldwide?clientrequestid=b794baa0-662f-4592-b4f0-46ab3284b612&ServiceAreas=Skype",
"name": "Microsoft Teams classic",
"rules": [
{
"action": "allow",
"process": "/Applications/Microsoft Teams classic.app/Contents/MacOS/Teams",
"remote-addresses": "13.107.64.0-13.107.127.255,52.112.0.0-52.115.255.255,52.122.0.0-52.123.255.255,2603:1063::-2603:1063:3ff:ffff:ffff:ffff:ffff:ffff",
"ports": "3478-3481",
"protocol": "udp"
@maxim
maxim / Excellent Karaoke Setup Guide.md
Last active December 24, 2022 03:12
An excellent high quality karaoke setup for under $1000

Excellent high quality karaoke setup for under $1000

For my Vietnamese wife a good karaoke setup is serious business. Problem is, I noticed that some people spend thousands of dollars on unnecessary stuff like gigantic receivers and speakers, only to end up with hiss, clipping, and clunky operation. Smart/consistent home setup should definitely fit under $1000, and that's with speakers and expensive Nvidia Shield box. You could definitely cut it to under $500 and still have a great setup. I did some research and put together a convenient setup for amazing quality at-home karaoke that isn't worth thousands, isn't a chore to operate, and passes Asian quality standards with flying colors.

How to use this setup once it's ready:

  1. You find any song on your phone's Youtube and cast it to your TV
  2. You pick up the microphone, start singing, and it all just sounds surprisingly beautiful

This guide assumes that you already have a TV with HDMI ARC or Optical/Coaxial audio output, and that you have WiFi at home.

def plain_text_receipt # => Runtime: 5 sec, Network Timeout
<<-TEXT
Thank you for your order!
Product: #{name} - #{price} # => 2 DB queries
Tax: #{tax_amount} # => 1 DB query, 1 API call
Total: #{total_amount} # => 2 DB queries, 1 API call
TEXT
end
private