This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn traverse_directory(dir_path: &str, parent: &str, files: &mut Vec<String>) { | |
if let Ok(entries) = fs::read_dir(dir_path) { | |
for entry in entries { | |
if let Ok(entry) = entry { | |
let file_type = entry.file_type().unwrap(); | |
let name = entry.file_name().into_string().unwrap(); | |
if file_type.is_dir() { | |
traverse_directory( | |
&entry.path().to_string_lossy(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let now = SystemTime::now(); | |
let duration = now.duration_since(UNIX_EPOCH).expect("Time went backwards"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// reqwest = { version = "0.11", features = ["multipart"] } | |
use reqwest::multipart::Part; | |
async fn upload_file() -> Result<(), Box<dyn std::error::Error>> { | |
let content: Vec<u8> = tokio::fs::read("path/to/file").await?; | |
let part = Part::bytes(content).file_name("file_name.extension"); | |
let file = reqwest::multipart::Form::new().part("field_name", part); | |
let response = reqwest::Client::new() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
main_profile=myprofile | |
mfa_profile=myprofile-mfa | |
mfa_device_arn=arn:aws:iam::999999999999:mfa/example_device | |
mfa_token_code=$1 | |
echo "Getting temporary credentials for MFA device..." | |
output=$(aws sts get-session-token --serial-number $mfa_device_arn --token-code $mfa_token_code --profile $main_profile) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const axios = require('axios'); | |
const Bluebird = require('bluebird'); | |
const { readFile: someOtherFnc } = require('fs'); | |
const app = express(); | |
// This is just a simulation | |
// real-life functions might not obviously simple for us to realize | |
async function simulateBlocker() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { execSync } = require('child_process'); | |
// Usage: compareBranches('branchA', 'branchB'); | |
compareBranches(branchA, branchB); | |
function getCommitMessages(branch) { | |
const command = `git log --pretty=format:'%s' ${branch}`; // Added %h to include commit hash | |
const output = execSync(command, { encoding: 'utf-8' }); | |
return output.trim().split('\n'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
Doctor.name, | |
Professor.name, | |
Singer.name, | |
Actor.name | |
from ( | |
select @p:=@p+1 iterator, name | |
from occupations, (SELECT @p:=0) p | |
where occupation = "Professor" | |
order by name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:18-alpine AS build | |
WORKDIR /app | |
COPY package*.json ./ | |
RUN npm ci | |
COPY . . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "PublicReadGetObject", | |
"Effect": "Allow", | |
"Principal": "*", | |
"Action": "s3:GetObject", | |
"Resource": "arn:aws:s3:::<bucket-name>/*" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET /_cluster/health | |
GET /_cat/indices?v | |
GET /_cat/nodes?v | |
GET /_cat/shards?v | |
### Add an index | |
PUT /products |