Skip to content

Instantly share code, notes, and snippets.

View asantos2000's full-sized avatar
🏠
Working from home

Anderson Santos asantos2000

🏠
Working from home
View GitHub Profile
@4wk-
4wk- / README.md
Last active May 16, 2025 08:27
Clean uninstall then reinstall of WSL on Windows 10, with systemD support

Uninstall then reinstall WSL on Windows 10 (clean way)

Background

I've been using wsl (version 2) with genie mod for years without issue, but one day, Windows 10 finally catch up on wsl Windows 11 features and gives us a way to use systemD natively.

I wanted to use the new "right way" to enable systemD on Windows Subsystem for Linux (without genie), and I also had a (probably related) infinite Windows RemoteApp error poping in.

Fixing it

A - Uninstall wsl and related stuff

  1. In powershell (as admin)
@asantos2000
asantos2000 / dredd.sh
Created June 25, 2018 12:51
Run dredd image as a command line
#!/bin/bash
echo '***'
echo 'Root dir is /api'
export MYIP=`ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'`
echo 'Configure URL of tested API endpoint: http://api-srv::<enpoint-port>. Set api-srv to point to your server.'
echo 'This script will set api-srv to docker host machine - ' $MYIP
echo 'Optional. Save this script in your PATH and give it an alias:'
echo "alias dredd='bash ./scripts/dredd.sh'"
echo '***'
#Reference: https://github.com/tzutalin/labelImg
#change en1 (wifi) for your connected network interface
export IP=$(ifconfig en1 | grep inet | awk '$1=="inet" {print $2}')
export DISPLAY=$IP:0
xhost +$IP
docker run -it \
-e DISPLAY=$DISPLAY \
--workdir="/home/$USER" \
# Reference: https://github.com/tzutalin/labelImg/issues/141
# create conda env using python 2.7
conda create -n py2 python=2.7
source activate py2
# install necessary libs using conda install
conda install pyqt=4
conda install libxml2
conda install lxml
@sorjef
sorjef / converter-cli.js
Last active January 18, 2022 14:56
Script to convert AWS Data Pipeline template to Cloudformation template with a sample Terraform module
const fs = require('fs');
const Converter = require('./converter.js');
const options = {
name: process.argv[3],
description: process.argv[4],
activate: process.argv[5],
};
const converter = new Converter(JSON.parse(fs.readFileSync(process.argv[2])), options);
{
"Comment": "Applying the Saga pattern with AWS Lambda and Step Functions",
"StartAt": "BookHotel",
"States": {
"BookHotel": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:{AccountID}:function:lambda-saga-dev-book-hotel",
"Catch": [
{
"ErrorEquals": ["States.ALL"],
@werbth
werbth / ResizeImage.java
Last active December 24, 2022 04:05
Given a jpeg image as InputStream, resize it and return another InputStream.
// formatName: the image format name (jpeg, png)
public static InputStream resizeImage(InputStream inputStream, int width, int height, String formatName) throws IOException {
BufferedImage sourceImage = ImageIO.read(inputStream);
Image thumbnail = sourceImage.getScaledInstance(width, height, Image.SCALE_SMOOTH);
BufferedImage bufferedThumbnail = new BufferedImage(thumbnail.getWidth(null),
thumbnail.getHeight(null),
BufferedImage.TYPE_INT_RGB);
bufferedThumbnail.getGraphics().drawImage(thumbnail, 0, 0, null);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(bufferedThumbnail, formatName, baos);
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Sends HAL signals to the given MQTT broker host.
#
# usage: hal2mqtt.py [hostname]
#
# Video demo at https://www.youtube.com/watch?v=uFbr7xBjItE
#
# sudo apt-get install mosquitto mosquitto-clients python-mosquitto
@jeffweiss
jeffweiss / emit_log.exs
Last active June 29, 2022 21:02
RabbitMQ Tutorial - Elixir examples
{:ok, connection} = AMQP.Connection.open
{:ok, channel} = AMQP.Channel.open(connection)
message = Enum.join(System.argv, " ") || "Hello World!"
AMQP.Exchange.declare(channel, "logs", :fanout)
AMQP.Basic.publish(channel, "logs", "", message)
IO.puts " [x] Sent '#{message}'"