Skip to content

Instantly share code, notes, and snippets.

View haydanu's full-sized avatar
💭
I may be slow to respond.

danu haydanu

💭
I may be slow to respond.
View GitHub Profile
@coltenkrauter
coltenkrauter / fix-wsl2-dns-resolution
Last active June 29, 2024 09:47
Fix DNS resolution in WSL2
More recent resolution:
1. cd ~/../../etc (go to etc folder in WSL).
2. echo "[network]" | sudo tee wsl.conf (Create wsl.conf file and add the first line).
3. echo "generateResolvConf = false" | sudo tee -a wsl.conf (Append wsl.conf the next line).
4. wsl --terminate Debian (Terminate WSL in Windows cmd, in case is Ubuntu not Debian).
5. cd ~/../../etc (go to etc folder in WSL).
6. sudo rm -Rf resolv.conf (Delete the resolv.conf file).
7. In windows cmd, ps or terminal with the vpn connected do: Get-NetIPInterface or ipconfig /all for get the dns primary and
secondary.
@ruandre
ruandre / s3-bucket-exists.js
Last active February 8, 2022 05:36
Check if S3 bucket exists using AWS SDK JavaScript Node.js
const AWS = require('aws-sdk')
const s3 = new AWS.S3()
const BUCKET_NAME = 'MyBucket'
async function main() {
try {
const data = await s3.headBucket({ Bucket: BUCKET_NAME }).promise()
return `Bucket "${BUCKET_NAME}" exists`
let outputs = []
function printSequence(strings) {
const optionsRange = []
const alphabets = strings.toUpperCase().split('')
const functionQueues = []
let count = 1
if (alphabets.length < 9) {
for (let index = 0; index <= alphabets.length; index++) {
@jjvillavicencio
jjvillavicencio / setup.sh
Last active May 26, 2024 18:37
Install Android SDK on Windows Bash (WSL)
cd /home/<user>/
sudo apt-get install unzip
wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
unzip sdk-tools-linux-4333796.zip -d Android
rm sdk-tools-linux-4333796.zip
sudo apt-get install -y lib32z1 openjdk-8-jdk
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/bin
printf "\n\nexport JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64\nexport PATH=\$PATH:\$JAVA_HOME/bin" >> ~/.bashrc
cd Android/tools/bin
@josephhanson
josephhanson / MockFile.js
Last active December 12, 2023 16:51
Mock file for JavaScript based file upload - with basic test harness
// mock file
function MockFile() { };
MockFile.prototype.create = function (name, size, mimeType) {
name = name || "mock.txt";
size = size || 1024;
mimeType = mimeType || 'plain/txt';
function range(count) {
var output = "";
@flangofas
flangofas / ConvertMS.js
Last active June 1, 2024 04:00
JS: Convert Milliseconds to days? minutes? seconds? or all!
function convertMiliseconds(miliseconds, format) {
var days, hours, minutes, seconds, total_hours, total_minutes, total_seconds;
total_seconds = parseInt(Math.floor(miliseconds / 1000));
total_minutes = parseInt(Math.floor(total_seconds / 60));
total_hours = parseInt(Math.floor(total_minutes / 60));
days = parseInt(Math.floor(total_hours / 24));
seconds = parseInt(total_seconds % 60);
minutes = parseInt(total_minutes % 60);