Skip to content

Instantly share code, notes, and snippets.

View spdrman's full-sized avatar

Roman spdrman

View GitHub Profile

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
@spdrman
spdrman / pdf2svgs.py
Created December 27, 2022 01:49 — forked from vitchyr/pdf2svgs.py
Convert PDF to multiple SVGs with Inkscape and pyPdf
"""
Author: Vitchyr Pong
Convert a PDF to svg files. Note that this is pretty slow since it makes
subprocess calls to inkscape's PDF-to-SVG command line convert.
Requirements:
- Inkscape (https://inkscape.org/)
- pyPdf (http://pybrary.net/pyPdf/)
- A '/tmp' directory. If not, you must pass in another directory.
@spdrman
spdrman / hma-scheduled-runner.sh
Last active October 4, 2022 02:34 — forked from kodekracker/hma-scheduled-runner.sh
Openvpn Scheduler
#!/bin/bash
################################################
# A SIMPLE SCHEDULE IP CHANGE SCRIPT FOR LINUX #
# MAKE SURE YOU HAVE RUN hma-udp-grabber.sh #
################################################
OPENVPNCONFIG_PATH="/etc/openvpn"
while true
do
#openvpn --daemon --config ${OPENVPNCONFIG_PATH}/Afghanistan.Kabul.TCP.ovpn # <<<< change the config file string to match your prefered server
openvpn --daemon --config ${OPENVPNCONFIG_PATH}/USA.Seattle.TCP.ovpn
@spdrman
spdrman / fib.rs
Created July 7, 2022 03:58 — forked from mjs/fib.rs
Fibonacci sequence generation done in 3 ways using Rust
const ITERS: usize = 20;
fn print_fib(n: usize) {
let mut x = (1, 1);
for i in 0..n {
println!("{}: {}", i, x.0);
x = (x.1, x.0 + x.1)
}
}
@spdrman
spdrman / string-conversion.rs
Created July 1, 2022 05:10 — forked from jimmychu0807/string-conversion.rs
Conversion between String, str, Vec<u8>, Vec<char> in Rust
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();
// to vec of byte
@spdrman
spdrman / Installation Guide
Created May 31, 2022 16:01 — forked from hkaraoguz/Installation Guide
How to install Nvidia 470.57.02 Drivers for Ubuntu 20.04 using a run file
## Install necessary libraries
sudo apt update &&
sudo apt install build-essential libglvnd-dev pkg-config
## Download the drivers
wget https://us.download.nvidia.com/XFree86/Linux-x86_64/470.57.02/NVIDIA-Linux-x86_64-470.57.02.run
## Remove the existing Nvidia drivers, utils, libs etc.
sudo apt purge nvidia*
sudo apt purge nvidia-driver*
@spdrman
spdrman / Concepts.md
Last active June 1, 2022 23:44 — forked from DarinM223/Concepts.md
Rust concept explanations

My explanation of the main concepts in Rust

There are three main concepts with Rust:

  1. Ownership (only one variable "owns" the data at one time, and the owner is in charge of deallocating)
  2. Borrowing (you can borrow a reference to an owned variable)
  3. Lifetimes (all data keeps track of when it will be destroyed)

These are fairly simple concepts, but they are often counter-intuitive to concepts in other languages, so I wanted to give a shot at

Screen Quick Reference

Basic

Description Command
Start a new session with session name screen -S <session_name>
List running sessions / screens screen -ls
Attach to a running session screen -x
Attach to a running session with name screen -r
@spdrman
spdrman / reset.css
Created May 14, 2022 01:56 — forked from simonausten/reset.css
Email CSS Reset
<style type="text/css">
/****** EMAIL CLIENT BUG FIXES - BEST NOT TO CHANGE THESE ********/
.ExternalClass {
width: 100%;
}
/* Forces Outlook.com to display emails at full width */
.ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div { line-height: 100%; }
/* Forces Outlook.com to display normal line spacing, here is more on that: http://www.emailonacid.com/forum/viewthread/43/ */
@spdrman
spdrman / Useful Crates.md
Last active February 7, 2022 17:01
Awesome Rust

Cargo like npm

  • cargo-watch watches over your project's source for changes, and runs Cargo commands
  • cargo-edit add, remove, and upgrade dependencies by modifying your Cargo.toml

CLI

  • clap // Command Line Argument Parser for Rust
  • structopt // Parse command line arguments by defining a struct. It combines clap with custom derive.