This file contains 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
class Utilities { | |
public static isValidStringHeaders(headers: string): boolean { | |
const regex = /^[a-zA-Z0-9,_]+$/; | |
return regex.test(headers); | |
} | |
public static isValidStringHeaders(headers: string): boolean { | |
const allowedCharacters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_,'; | |
for (let i = 0; i < headers.length; i++) { |
This file contains 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
type StringMap = Map<string, string>; | |
export class ResultT<T> { | |
value: T | null; | |
errors: StringMap; | |
constructor() { | |
this.value = null; | |
this.errors = new Map<string, string>(); | |
} |
This file contains 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
public void Print(HttpClient httpClient){ | |
var jsonContent = await response.Content.ReadAsStringAsync(); | |
Console.WriteLine($"curl -X {httpClient.HttpRequestMessage.Method} \"{url}\" \\\n" + | |
$"{GetHeadersAsString(httpClient.HttpRequestMessage.Headers)} \\\n" + | |
$"-d \"{jsonContent}\""); | |
} | |
static string GetHeadersAsString(HttpHeaders headers) | |
{ |
This file contains 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
#Checks for the presence of directory /usr/local/go/bin in $PATH. | |
echo "$PATH" | grep -q -E "(^|:)/usr/local/go/bin($|:)" | |
is_present=$? | |
if [ $is_present -eq 1 ]; then | |
export PATH=$PATH:/usr/local/go/bin | |
echo "add go bin" | |
fi |
This file contains 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
type ResultT struct { | |
Response interface{} | |
Errors map[string]string | |
} | |
func NewResultT() ResultT { | |
return ResultT{ | |
Response: nil, | |
Errors: make(map[string]string), | |
} |
This file contains 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
use std::collections::HashMap; | |
pub struct ResultT<T> { | |
response: Option<T>, | |
errors: HashMap<String, String>, | |
} | |
impl<T> ResultT<T> { | |
pub fn new() -> Self { | |
ResultT { |
This file contains 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
public static class EnumExtensions | |
{ | |
public static T? GetDefaultValue<T>() where T : Enum | |
{ | |
var enumType = typeof(T); | |
var defaultValueAttribute = Attribute | |
.GetCustomAttribute(enumType, typeof(DefaultValueAttribute)) as DefaultValueAttribute; | |
if (defaultValueAttribute is not null && | |
defaultValueAttribute.Value is T) |
This file contains 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 pyspark import SparkContext | |
import os | |
ip = os.popen("ifconfig en0 | grep inet | grep -v inet6 | awk '{print $2}'").read().strip() | |
os.environ['SPARK_LOCAL_IP'] = ip | |
#bash> export SPARK_LOCAL_IP=$(ifconfig en0 | grep inet | grep -v inet6 | awk '{print $2}') | |
sc = SparkContext() | |
sc.setLogLevel("OFF") |
This file contains 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 main() { | |
let initial_investment = -1000.0; | |
let cash_receipts = vec![250.0, 350.0, 450.0, 550.0]; | |
let cash_flows = vec![initial_investment, | |
cash_receipts[0], cash_receipts[1], cash_receipts[2], cash_receipts[3]]; | |
let rate = irr(&cash_flows); | |
println!("IRR: {:.2}%", rate * 100.0); | |
} |
This file contains 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
# Transfer folder with files to vm | |
scp -r -i certificate.pem home/userlocal/diretory uservm:ip_vm_host home/uservm/directory | |
# Connect to vm | |
ssh -i certificate.pem uservm:ip_vm_host | |
# INSTALL .NET 7 | |
# 1) Add package | |
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb | |
sudo dpkg -i packages-microsoft-prod.deb |
NewerOlder