Skip to content

Instantly share code, notes, and snippets.

View aaomidi's full-sized avatar

Amir Omidi aaomidi

  • Spirl
  • US
View GitHub Profile
@aaomidi
aaomidi / options.go
Last active January 24, 2025 15:54
Pulumi doesn't have a good way of combining resource and invoke options into a single container that we can pass down to functions. This solves that problem. Keywords: pulumi.ResourceOrInvokeOption
/*
Copyright 2025 SPIRL
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DE
@aaomidi
aaomidi / ghc.sh
Created November 20, 2023 01:44
Organize your github clones automatically
#!/usr/bin/env bash
# Extract the organization and repo name from the argument
ORG=$(echo "$1" | cut -d '/' -f 1)
REPO=$(echo "$1" | cut -d '/' -f 2)
# Define the base directory
BASE_DIR="$HOME/Projects"
# Create the directory structure
package main
import (
"bytes"
"flag"
"fmt"
"go/ast"
"go/parser"
"go/printer"
"go/token"
Item #: SCP-XXXX
Object Class: Euclid
Special Containment Procedures: The process of going from draft to published Request for Comments (RFC) at the Internet Engineering Task Force (IETF) is to be closely monitored and documented by Foundation agents embedded within the IETF. These agents are to observe and record any deviations from standard protocol, as well as any anomalous activity that may occur during the process.
Any anomalous activity discovered during the process is to be reported immediately to the IETF Security Area Directors and the Foundation's Director of Information Security. The anomalous activity is to be contained and neutralized as quickly and efficiently as possible, with minimal disruption to the normal operation of the IETF.
Description: SCP-XXXX is the process of going from draft to published RFC at the IETF. This process involves multiple steps, including:
@aaomidi
aaomidi / Dockerfile
Last active January 18, 2022 16:01
firewalld blocking DNS when running in docker-compose & sysbox runtime
FROM centos:8
ENTRYPOINT [ "/sbin/init", "--log-level=err" ]
RUN yum install -y systemd openssh-server openssh-server bind-utils nc
RUN echo "root:1" | chpasswd
RUN echo "PermitRootLogin yes" > /etc/ssh/sshd_config
RUN yum install -y firewalld
@aaomidi
aaomidi / nat_rules
Last active September 2, 2018 15:39
Script to run the VPN
nat on utun2 from 192.168.2.0/24 to any -> (utun2)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Subnets</key>
<array>
<dict>
<key>allocate</key>
<true/>
<key>dhcp_domain_name_server</key>

There's been some active discussion on "Is this the switch expression construct we're looking for" over on amber-dev. Its a good time to take stock of where we are, and identifying any loose ends.

Approach

Our approach is driven not merely by the desire to have an expression form of switch, but to make switch more generally useful as a multi-way conditional construct. The biggest driver here of course is making it work well with pattern matching. Pattern matching is a driver for better

@aaomidi
aaomidi / AbstractClass.java
Last active December 5, 2017 17:42
Funky Java :)
public abstract class AbstractClass {
public void printClass() {
System.out.println(this.getClass().getName());
System.out.println(getClass().getName());
}
}
@aaomidi
aaomidi / Midterm.md
Created March 24, 2017 06:31
CS370 Midterm

CS370

Midterm

Question 1

Suppose as a programmer you have three options for providing mutual exclusion: disabling interrupts, a spin lock, and semaphores. What considerations would go into your decision for choosing one over the others?

  • Interrupt Control:

It simply does not allow the OS to preempt processes. If we're given one choice of these to provide mutex, this would, simply, be the worst idea possible. It could allow any process take over the entire CPU. For safety and santiy's sake this should be avoided.