Skip to content

Instantly share code, notes, and snippets.

@erdesigns-eu
erdesigns-eu / vue.ts
Last active May 13, 2024 15:04
Find child components in a Vue3 component. (Alternative for Vue2 $children)
/**
* Find all Vue components that match the given matcher and return them in an array.
* @param parent The parent component to search.
* @param matcher The matcher to use.
* @returns An array of components that match the given matcher.
*/
export const findVueChildComponents = (parent: any, matcher: RegExp | String | undefined) => {
const found: any[] = [];
const root = parent.$.subTree;
@PokerGuy
PokerGuy / gist:5cdfc4ef146ce6b535bfd8e13469a2ab
Last active May 13, 2024 15:03
Push a file to SharePoint
const push = async (file, fileName) => {
const client = new aws.SecretsManager();
const spURL = `https://<your site>.sharepoint.com/sites/<your specific subsite>/_api/web/GetFolderByServerRelativeUrl('Documents')/Files/Add(url='${fileName}', overwrite=true)`;
try {
const data = await client.getSecretValue({ SecretId: '<whatever you called your secret>' }).promise();
const secret = JSON.parse(data.SecretString).<whatever you called your secret>;
const getToken = await axios.post('https://accounts.accesscontrol.windows.net/<sharepoint resource id>/tokens/OAuth/2',
querystring.stringify({
grant_type: 'client_credentials',
client_id: '<ask your sharepoint person for this it's a something@tenant id>',
@nitred
nitred / optimal_mtu.md
Last active May 13, 2024 15:03
Wireguard Optimal MTU

About

  • I faced bandwidth issues between a WG Peer and a WG server. Download bandwidth when downloading from WG Server to WG peer was reduced significantly and upload bandwidth was practically non existent.
  • I found a few reddit posts that said that we need to choose the right MTU. So I wrote a script to find an optimal MTU.
  • Ideally I would have liked to have run all possible MTU configurations for both WG Server and WG Peer but for simplicity I choose to fix the WG Server to the original 1420 MTU and tried all MTUs from 1280 to 1500 for the WG Peer.

Testing

  • On WG server, I started an iperf3 server
  • On WG peer, I wrote a script that does the following:
    • wg-quick down wg0
  • Edit MTU in the /etc/wireguard/wg0.conf file
@harshavardhana
harshavardhana / nginx-minio-static.md
Last active May 13, 2024 15:03 — forked from koolhead17/gist:4b8dd8d95ec86368634693cf9ad9391c
How to configure static website using Nginx with MinIO ?

How to configure static website using Nginx with MinIO ?

1. Install nginx

2. Install minio

3. Install mc client

4. Create a bucket:

$ mc mb myminio/static
Bucket created successfully ‘myminio/static’.
# import nothing
"""
Tested in cpython 3.6, 3.8 (from the arch repos) on 64-bit arch linux
"""
nullfunc = lambda: None
#from types import CodeType, FunctionType
CodeType = nullfunc.__code__.__class__
FunctionType = nullfunc.__class__

Transparent Restaurant Backend

In this task, you're going to implement a REST API for a interacting with a menu of a restaurant. The menu is given to you as a JSON file which you will parse and perform operations on. The required features will be listed below.

Description

In this restaurant, honesty is extremely promoted. So extreme, that the restaurant declares that differing quality of ingredients are used in their meals. Like that's not enough, it also allows the customers to choose the ingredients of each meal in different qualities. Each ingredient has the following quality levels:

  • low: the cheapest
  • medium: moderate
@lukeplausin
lukeplausin / transfer_ssm_file.sh
Last active May 13, 2024 15:00
Transfer a file to EC2 SSM instance without using S3 (SSM only)
# This script will explain how to transfer a file to EC2 using SSM ONLY!
# You will need to have permission to run SSM commands on the target machine and have sudo access as well
# Infos
INSTANCE_ID=i-1234567890
FILE_NAME=the_file.tar.gz
# Step 1: Run command on machine to install netcat and dump from port to filename
# < Start session
@ayoubzulfiqar
ayoubzulfiqar / folder_structure.md
Created September 5, 2023 06:12
The Folder Structure for Every Golang Project

Go - The Ultimate Folder Structure

Organizing your Go (Golang) project's folder structure can help improve code readability, maintainability, and scalability. While there is no one-size-fits-all structure, here's a common folder structure for a Go project:

project-root/
    ├── cmd/
    │   ├── your-app-name/
    │   │   ├── main.go         # Application entry point
    │   │   └── ...             # Other application-specific files
! [SYNTAX] https://help.adblockplus.org/hc/en-us/articles/360062733293
/banhkhuc/,/thapcam/,/xoilac/,/90phut/,/vebo/##.box-host.box
/banhkhuc/,/thapcam/,/xoilac/,/90phut/,/vebo/##.vebo-sp.container
/banhkhuc/,/thapcam/,/xoilac/,/90phut/,/vebo/##.mc_padding
/banhkhuc/,/thapcam/,/xoilac/,/90phut/,/vebo/##.to-left
/banhkhuc/,/thapcam/,/xoilac/,/90phut/,/vebo/##.to-right
/banhkhuc/,/thapcam/,/xoilac/,/90phut/,/vebo/##.ft-box,
/banhkhuc/,/thapcam/,/xoilac/,/90phut/,/vebo/##.sidebar-right,
/banhkhuc/,/thapcam/,/xoilac/,/90phut/,/vebo/##.jw-logo.jw-logo-bottom-right.jw-reset

Config files

To configure Zsh for your user’s session, you can use the following files:

  • $ZDOTDIR/.zshenv
  • $ZDOTDIR/.zprofile
  • $ZDOTDIR/.zshrc
  • $ZDOTDIR/.zlogin
  • $ZDOTDIR/.zlogout

By default, Zsh will try to find the user’s configuration files in the $HOME directory. You can change it by setting the environment variable $ZDOTDIR.