Skip to content

Instantly share code, notes, and snippets.

@ezzabuzaid
ezzabuzaid / compute.js
Last active April 17, 2024 05:49
Simple inline web worker helper. compute version of Dart in JavaScript.
function compute(computation, ...message) {
const delegate = () => {
onmessage = ({ data: { computation, message } }) => {
const wrapper = (fn) => Function('"use strict"; return (' + fn.toString() + ')')();
const result = wrapper(computation)(...message);
postMessage(result);
};
}
const functionBody = delegate.toString().replace(/^[^{]*{\s*/, '').replace(/\s*}[^}]*$/, '');
return new Promise((resolve, reject) => {
@imfioki
imfioki / WinSCP_Upload_SFTP.ps1
Created June 14, 2019 03:15
Uploading files to SFTP server using Powershell, WinSCP .NET Assembly, AWS SSM Parameter Store, SSH keys, and monitoring via AWS SNS notifications
# Download and install .NET assembly at: https://winscp.net/eng/downloads.php#additional
# This process will send SNS notifications upload upload failure.
# Define connection parameters and globals
$server = '<127.0.0.1>'
$sftpUser = '<sftp_user>'
$ssmParam = '<sftp_password>'
$awsRegion = '<us-east-1>'
$snsTopic = '<sns_topic>'
$snsSubject = 'An error has occurred in production SFTP[IAM]'
$sftp_pass = (Get-SSMParameter -Region $awsRegion -Name $ssmParam -WithDecryption $true).Value
@Davor111
Davor111 / sshuttle.sh
Created February 17, 2017 08:34
How to use sshuttle with .key, .csr or .pem files for authentication
#It's not directly mentioned in the documentation on how to do this, so here you go. This command will tunnel everything including DNS:
sshuttle --dns -vr user@yourserver.com 0/0 --ssh-cmd 'ssh -i /your/key/path.pem'