trymeout

joined 1 year ago
[–] [email protected] 0 points 2 weeks ago

Thank for sharing rust-script which is basically what I made but written in Rust and seems to store the binary in another directory when the binary is exexuted.

Is the RFC trying to introduce a command cargo script to run single rust scripts?

[–] [email protected] 0 points 2 weeks ago (2 children)

It could be done with a one liner in the terminal but adding arguments when running the binary will be in the middle of the command, not at the end of the command.

Also the usecase for me is for sample scripts I have. This makes it easy to compile, run and delete the binary.

 

I would like to share a bash script I made for when you want to simply run a rust script once and delete it. Instead of having compile the script with rustc, running the binary and then deleting the binary, you can achive all of this with this bash script below.

The first argument will be the rust script file name. The .rs file extension is optional. The rest of the arguments are passed into the executed binary.

Simply name the bash script to something like rust-run.sh.

#!/bin/bash

#Get file path from first parameter
path=$(dirname "$1")

#Get file name from first parameter
fileName=$(basename "$1")
fileName="${fileName%'.rs'}"

#Compile executable and save it in the same directory as the rust script
rustc "${path}/${fileName}.rs" -o "${path}/${fileName}"

#If rustc commands retuned any errors, unable to compile the rust script
if [ $? -ne 0 ]; then
    return
fi

#Execute compilled executable and pass the rest of the parameters into the executable
"${path}/${fileName}" ${*:2}

#Delete compillled executable
rm "${path}/${fileName}"

If someone wants to rewrite this in rust or add these features into the rustc, feel free to do so.

 

I would like to share a bash script I made for when you want to simply run a rust script once and delete it. Instead of having compile the script with rustc, running the binary and then deleting the binary, you can achive all of this with this bash script below.

The first argument will be the rust script file name. The .rs file extension is optional. The rest of the arguments are passed into the executed binary.

Simply name the bash script to something like rust-run.sh.

#!/bin/bash

#Get file path from first parameter
path=$(dirname "$1")

#Get file name from first parameter
fileName=$(basename "$1")
fileName="${fileName%'.rs'}"

#Compile executable and save it in the same directory as the rust script
rustc "${path}/${fileName}.rs" -o "${path}/${fileName}"

#If rustc commands retuned any errors, unable to compile the rust script
if [ $? -ne 0 ]; then
    return
fi

#Execute compilled executable and pass the rest of the parameters into the executable
"${path}/${fileName}" ${*:2}

#Delete compillled executable
rm "${path}/${fileName}"

If someone wants to rewrite this in rust or add these features into the rustc, feel free to do so.

 

Should I create functions/methods for packages/libraries that allow optional parameters to accept null?

In this example below, I set the 3rd and 4th parameter as null which will act as the default value.

myLibrary.myFunction(1, 7, null, null, true);

Or is this not a good way to go about creating functions for a package and therefore should not accept null as a parameter value.

myLibrary.myFunction(1, 7, false, 4, true);
 

Should I create functions for packages/libraries that allow optional parameters to accept null?

In this example below, I set the 3rd and 4th parameter as null which will act as the default value.

myLibrary::myFunction(1, 7, null, null, true);

Or is this not a good way to go about creating functions for a package and therefore should not accept null as a parameter value.

myLibrary::myFunction(1, 7, false, 4, true);
 

Just started learning Rust today and got Rust installed, got the hello world example compiled and running. I installed rust-analyzer and CodeLLDB extensions in VSCode. Enable the debug.allowBreakpointsEverywhere settings to VSCode to be true. Setup a debug configuration in VSCode.

However I keep getting errors from rust-analyzer when I run the debugger...

2024-10-06T22:16:04.808655Z ERROR FetchWorkspaceError: rust-analyzer failed to load workspace: Failed to load the project at /home/john/Documents/Snippets/Rust/Cargo.toml: Failed to read Cargo metadata from Cargo.toml file /home/john/Documents/Snippets/Rust/Cargo.toml, Some(Version { major: 1, minor: 81, patch: 0 }): Failed to run `cd "/home/john/Documents/Snippets/Rust" && RUSTUP_TOOLCHAIN="/home/john/.rustup/toolchains/stable-x86_64-unknown-linux-gnu" "/home/john/.cargo/bin/cargo" "metadata" "--format-version" "1" "--manifest-path" "/home/john/Documents/Snippets/Rust/Cargo.toml" "--filter-platform" "x86_64-unknown-linux-gnu"`: `cargo metadata` exited with an error: error: failed to parse manifest at `/home/john/Documents/Snippets/Rust/Cargo.toml`

Caused by:
  no targets specified in the manifest
  either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present

I not sure how to fix this.

I would like to get the VSCode debugger to work for launch debugging, attach debugging and launch and attach debugging for rust running inside a docker container. This will be a good setup for getting started I believe.

This is my VSCode debugger configuration...

{
	// Use IntelliSense to learn about possible attributes.
	// Hover to view descriptions of existing attributes.
	// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
	"version": "0.2.0",
	"configurations": [
		{
			"type": "lldb",
			"request": "launch",
			"name": "Debug",
			"program": "${workspaceFolder}/hello-world",
			"args": [],
			"cwd": "${workspaceFolder}"
		}
	]
}

Any help and advice will be most appreciated.

[–] [email protected] 1 points 1 month ago

I knew of Grayjay but did not know it was open source now. A lot of the app is written in Kotlin which is promising for cross platform

[–] [email protected] 1 points 1 month ago

Cross platform

[–] [email protected] 1 points 1 month ago

None of the are available for both mobile and desktop

[–] [email protected] 2 points 1 month ago

It can be cross platform. On mobile and desktop

[–] [email protected] 2 points 1 month ago

True. I did make a feature request to have the Newpipe Extractor in the app

https://github.com/mu-fazil-vk/FluxTube/issues/44

 

When I submit the form twice, three times, etc. I get duplicated form field data. Here is the console output of the form data after every submissions.

Also all the field values are always an array, even if the input field for that value is a text input field? Not sure if this is another issue or not.

Here is my code. Only one JS file and one HTML file...

import fs from 'fs';
import http from 'http';

import { formidable as formidablePackage } from 'formidable';

const port = 8080;

//Will create horizontal line that will fit the width of the terminal window
const horizontalLine = '='.repeat(process.stdout.columns);

const formidable = formidablePackage({
	allowEmptyFiles: true,
	minFileSize: 0,
});

http
	.createServer(async (request, response) => {
		if (request.method === 'POST') {
			let [formFieldData, formFileData] = await formidable.parse(request);

			console.log(formFieldData);
		}

		response.setHeader('Content-Type', 'text/html');

		fs.createReadStream('form.html').pipe(response);
	})
	.listen(port);
<form method="post" enctype="multipart/form-data">
	<input name="myText" />
	<br />
	<input type="checkbox" name="myCheckboxGroupA" />
	<input type="checkbox" name="myCheckboxGroupA" />
	<input type="checkbox" name="myCheckboxGroupA" />
	<br />
	<input type="file" name="myFileA" />
	<br />
	<input type="file" name="myFileB" multiple />
	<br />
	<input type="file" name="myFileC" multiple directory webkitdirectory />
	<br />
	<input type="submit" />
</form>

These are the console logs

$ node form.js
{ myText: [ 'hello world' ], myCheckboxGroupA: [ 'on' ] }
{
  myText: [ 'hello world', 'hello world' ],
  myCheckboxGroupA: [ 'on', 'on' ]
}
{
  myText: [ 'hello world', 'hello world', 'hello world' ],
  myCheckboxGroupA: [ 'on', 'on', 'on' ]
}
{
  myText: [ 'hello world', 'hello world', 'hello world', 'hello world' ],
  myCheckboxGroupA: [ 'on', 'on', 'on', 'on' ]
}

These are the console logs I expected

$ node form.js
{ myText:  'hello world' , myCheckboxGroupA: [ 'on' ] }
{ myText:  'hello world' , myCheckboxGroupA: [ 'on' ] }
{ myText:  'hello world' , myCheckboxGroupA: [ 'on' ] }
{ myText:  'hello world' , myCheckboxGroupA: [ 'on' ] }
 

I hope this project gets more contributors to help make it as good or better than Newpipe. Written in Dart using Flutter can allow it to be compiled for Android, iOS and desktop

[–] [email protected] 2 points 2 months ago (4 children)

Is it hard for modders to update their CSGO maps to work in CS2?

[–] [email protected] 3 points 2 months ago* (last edited 2 months ago)

Oh yeah sure let’s just have two games that are almost identical, split the efforts of the devs into maintaining them both and releasing consistent updates, split the efforts of the server administrators into maintaining them both, and detract from your concurrent player base from our new game to keep our old game on life support.

Yall are some crybabies. CS:GO was alive for 10 years, CS2 has been out for 1. It took some time to re-work Dust 2 and add it back into the map pool. I miss agency, I miss cache, but those maps are being reworked and added in over time. It’s a long game scenario here. Give it time and enjoy the free to play game that they sunk a shitload of resources into dramatically improving, that they are going to maintain for at least another decade, just like the last game.

Wow, you need chill out. Just asking a simple question.

 

In CSGO you could change the difficulty setting for the bots. Can you adjust the difficulty setting for bots in CS2?

[–] [email protected] 2 points 2 months ago (9 children)

Why did they update CSGO into CS2 instead of releasing CS2 as a new game?

 

Are CSGO workshop maps not compatible with CS2? Does this mean that the 200+ custom workshop maps I have collected over the years are now no longer playable?

I cannot see any workshop maps in the game menu that I have subscribed and downloaded. I even tried to reinstall CS2 on my computer to see if that will fix the problem.

I am running CS2 on Ubuntu (Linux)

[–] [email protected] 1 points 2 months ago

Would like to see an Android version as well that has its own F-Droid repo

 

Upvote the issue on Github if you want to see this feature added into VSCode.

 

I am trying to create a podman compose of NGINX and PHP:FPM. I was able to get NGINX to work on its own using the docker.io./bitnami/nginx image. I gotten close I believe to getting the PHP:FPM to work also but due to an issue with NGINX not cooperating with the PHP:FPM.

In the logs of the NGINX container, I get this error every time I load localhost:8080 in the browser...

10.89.4.2 - - [24/Jul/2024:20:18:35 +0000] "GET / HTTP/1.1" 404 47 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0" "-"
2024/07/24 20:18:35 [error] 44#44: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 10.89.4.2, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://10.89.4.3:9000", host: "localhost:8080"

And when I load localhost:8080 in the browser, it displays a blank page which says "File not found.".

I am using podman 5.1.2 on Linux Mint 21.3. My goal is to simply NGINX and PHP to work, to be able to have a web server that can use PHP.

Any advice would be most appreciated.


Directory structure

nginx-php/
   compose.yml
   nginx.conf
   php.dockerfile
   php.ini
   www/
      public/

compose.yml

version: '3'
networks:
    app-tier:
        driver: bridge
services:
    nginx:
        image: docker.io/bitnami/nginx
        volumes:
            - ./nginx.conf:/opt/bitnami/nginx/conf/server_blocks/my_server_block.conf:ro
            - .:/app/
        networks:
            - app-tier
        ports:
            - 8080:8080
    php:
        build:
            context: .
            dockerfile: php.dockerfile
        volumes:
            - .:/app/
        networks:
            - app-tier

nginx.conf

server {
    server_name localhost;
    listen 0.0.0.0:8080;
    
    root /app/www/public;

    index index.php index.html index.htm;
    autoindex on;

    location / {
        try_files $uri $uri/index.php;
    }

    location ~ \.php$ {
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
    }
}

php.dockerfile (Will like to get debugging and databases to work later on...)

FROM docker.io/bitnami/php-fpm

# Install xdebug for nicer error messages and debugging
# RUN pecl install xdebug
# RUN docker-php-ext-enable xdebug

# Install mysqli
# RUN docker-php-ext-install mysqli
# RUN docker-php-ext-enable mysqli

# Install PDO
# RUN docker-php-ext-install pdo pdo_mysql

php.ini (Will like to get debugging and databases to work later on...)

[PHP]

extension=mysqli
extension=pdo_mysql


; xdebug settings for debugging
zend_extension=xdebug
xdebug.start_with_request = yes
xdebug.client_host=xdebug://gateway

 

I was able to setup a debugger using a launch mode using Visual Studio Code with the Bash Debug extension. Is it possible to setup the debugger in VSCode to be able to debug a bash script using a attach debug mode?

For debugging scripts on the host machine and scripts inside a docker container?

view more: next ›