Skip to content

Instantly share code, notes, and snippets.

View maxim's full-sized avatar
🙂
🌴

Max Chernyak maxim

🙂
🌴
View GitHub Profile
@maxim
maxim / skype.lsrules
Last active March 28, 2024 00:11
Little Snitch rules for Skype, updated at 2024-03-28 00:11:45+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-new.lsrules
Last active March 28, 2024 00:11
Little Snitch rules for Microsoft Teams, updated at 2024-03-28 00:11:45+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"
@maxim
maxim / msteams.lsrules
Last active March 28, 2024 00:11
Little Snitch rules for Microsoft Teams classic, updated at 2024-03-28 00:11:45+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 / gh-dl-release
Last active March 3, 2024 07:09
Download assets from private Github releases
#!/usr/bin/env bash
#
# gh-dl-release! It works!
#
# This script downloads an asset from latest or specific Github release of a
# private repo. Feel free to extract more of the variables into command line
# parameters.
#
# PREREQUISITES
#
@maxim
maxim / tm2iterm.rb
Created June 10, 2012 04:04
Convert TextMate themes into iTerm 2 color schemes.
#!/usr/bin/env ruby
#
# This script is an astonishing feat of top notch
# rockstar craftsmanship. It totally uses artificial
# intelligence to extract colors out of tmTheme and
# build an itermcolors scheme file for iTerm2.
#
# I know this sounds crazy, but it actually knows
# approximately what colors should be used in the
# ANSI list, and tries to find nearest colors from
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") {