dankmememachine
dankmememachine
CC#
Created by dankmememachine on 4/2/2023 in #help
✅ Math problem related to drawing a line renderer relative to an object in Unity
Just to be clear again, this script shows an indicator of the trajectory that the object will take upon release of the mouse. But wherever you drag from the origin will now always be the player and the angle will always be relative to the object. If I drag under the object, the red line goes upwards in a straight line, if I drag downwards from 100 units to the right and 100 units high relative to the object, the red line goes upwards in a straight line.
4 replies
CC#
Created by dankmememachine on 4/2/2023 in #help
✅ Math problem related to drawing a line renderer relative to an object in Unity
Whelp, Chat gpt4 is pretty neat, here is a solution I made by modding this script and consulting with the robot: https://hatebin.com/nznqdqzsrs
4 replies
CC#
Created by dankmememachine on 3/15/2023 in #help
❔ How would I call a method created as a top level statement outside of the initial file?
there are other ways to do this, I was trying to see if there was a way to access a method defined as a top level statement elsewhere in the code
19 replies
CC#
Created by dankmememachine on 3/15/2023 in #help
❔ How would I call a method created as a top level statement outside of the initial file?
right that works, i was trying to create a code golf solution and wanted to keep the file at a minimum lines, i could not find a way to make that method accessible by another script in the shortest form that I first provided
19 replies
CC#
Created by dankmememachine on 3/15/2023 in #help
❔ How would I call a method created as a top level statement outside of the initial file?
I found a solution by refactoring the code I believe, it was changed since the original question. I was able to call by using a partial program class like so:
Test.TestMethod(args[0], args[1]);

public static partial class Program
{
public static int CountWords(string file, string word) => System.Text.RegularExpressions.Regex.Matches(File.ReadAllText(file), $@"\b{word}\b", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Count;
}
Test.TestMethod(args[0], args[1]);

public static partial class Program
{
public static int CountWords(string file, string word) => System.Text.RegularExpressions.Regex.Matches(File.ReadAllText(file), $@"\b{word}\b", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Count;
}
19 replies
CC#
Created by dankmememachine on 3/15/2023 in #help
❔ How would I call a method created as a top level statement outside of the initial file?
yes
19 replies
CC#
Created by dankmememachine on 3/15/2023 in #help
❔ How would I call a method created as a top level statement outside of the initial file?
and yes
19 replies
CC#
Created by dankmememachine on 3/15/2023 in #help
❔ How would I call a method created as a top level statement outside of the initial file?
it would be this script:
class Test
{
public static void TestMethod(string file, string word) => Console.WriteLine(Program.CountWords(file, word));
}
class Test
{
public static void TestMethod(string file, string word) => Console.WriteLine(Program.CountWords(file, word));
}
19 replies
CC#
Created by dankmememachine on 3/15/2023 in #help
❔ How would I call a method created as a top level statement outside of the initial file?
Console.WriteLine(CountWords(args[0], args[1]));
static int CountWords(string file, string word) => System.Text.RegularExpressions.Regex.Matches(File.ReadAllText(file), $@"\b{word}\b", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Count;
Console.WriteLine(CountWords(args[0], args[1]));
static int CountWords(string file, string word) => System.Text.RegularExpressions.Regex.Matches(File.ReadAllText(file), $@"\b{word}\b", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Count;
19 replies
CC#
Created by dankmememachine on 3/7/2023 in #help
❔ How to get specific fields from a Http GET request
Thank you for your help @Angius and @Axiss I'll take a look at optimizing my code and working further on this, I might post a question when it is finalized but I think this is about as much info as I need to continue. Sorry for not knowing much lmao
208 replies
CC#
Created by dankmememachine on 3/7/2023 in #help
❔ How to get specific fields from a Http GET request
I guess it might be hard to really request multiple of the same GET anyway, since I want to basically call one request, get an item from that category, then run the script again with a different request of category
208 replies
CC#
Created by dankmememachine on 3/7/2023 in #help
❔ How to get specific fields from a Http GET request
this would be for GET products/list
208 replies
CC#
Created by dankmememachine on 3/7/2023 in #help
❔ How to get specific fields from a Http GET request
Well it just provides an httpclient example from what I can see, and no mention of multiple calls at once:
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("https://apidojo-hm-hennes-mauritz-v1.p.rapidapi.com/products/list?country=us&lang=en&currentpage=0&pagesize=30&categories=men_trousers"),
Headers =
{
{ "X-RapidAPI-Key", "a807635214msh9feb01fd51a9cf7p19db7ajsnffb480f6b27a" },
{ "X-RapidAPI-Host", "apidojo-hm-hennes-mauritz-v1.p.rapidapi.com" },
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("https://apidojo-hm-hennes-mauritz-v1.p.rapidapi.com/products/list?country=us&lang=en&currentpage=0&pagesize=30&categories=men_trousers"),
Headers =
{
{ "X-RapidAPI-Key", "a807635214msh9feb01fd51a9cf7p19db7ajsnffb480f6b27a" },
{ "X-RapidAPI-Host", "apidojo-hm-hennes-mauritz-v1.p.rapidapi.com" },
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
208 replies
CC#
Created by dankmememachine on 3/7/2023 in #help
❔ How to get specific fields from a Http GET request
Right, this format is new to me, is there something I am missing in terms of docs here? or is it just reading through each GET and seeing what they accept?
208 replies
CC#
Created by dankmememachine on 3/7/2023 in #help
❔ How to get specific fields from a Http GET request
and will just interpolate the url three times, one for each clothing category
208 replies
CC#
Created by dankmememachine on 3/7/2023 in #help
❔ How to get specific fields from a Http GET request
Right now I have it set up barebones like:
private async void Start() => await StartAsync("men_trousers");

async Task StartAsync(string itemCategory)
{
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri($"https://apidojo-hm-hennes-mauritz-v1.p.rapidapi.com/products/list?country=us&lang=en&currentpage=0&pagesize=30&categories={itemCategory}"),
Headers =
{
{ "X-RapidAPI-Key", "a807635214msh9feb01fd51a9cf7p19db7ajsnffb480f6b27a" },
{ "X-RapidAPI-Host", "apidojo-hm-hennes-mauritz-v1.p.rapidapi.com" },
},
};
private async void Start() => await StartAsync("men_trousers");

async Task StartAsync(string itemCategory)
{
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri($"https://apidojo-hm-hennes-mauritz-v1.p.rapidapi.com/products/list?country=us&lang=en&currentpage=0&pagesize=30&categories={itemCategory}"),
Headers =
{
{ "X-RapidAPI-Key", "a807635214msh9feb01fd51a9cf7p19db7ajsnffb480f6b27a" },
{ "X-RapidAPI-Host", "apidojo-hm-hennes-mauritz-v1.p.rapidapi.com" },
},
};
208 replies
CC#
Created by dankmememachine on 3/7/2023 in #help
❔ How to get specific fields from a Http GET request
I just want to try to use good programming practices and minimize calls if I can, if not that is fine
208 replies
CC#
Created by dankmememachine on 3/7/2023 in #help
❔ How to get specific fields from a Http GET request
That I am unsure of, is there a way to test it? The api seems pretty barebones: https://rapidapi.com/apidojo/api/hm-hennes-mauritz/
208 replies
CC#
Created by dankmememachine on 3/7/2023 in #help
❔ How to get specific fields from a Http GET request
I guess my only other question is, should I simply call this
async Task StartAsync(string gender)
async Task StartAsync(string gender)
three times if I need say a shirt, a coat, and pants? the string there needs to be changed to the accessor for the categories such as
* //pants: men_trousers
* //jacket: men_blazerssuits
* //shirt: men_shirts */
* //pants: men_trousers
* //jacket: men_blazerssuits
* //shirt: men_shirts */
208 replies
CC#
Created by dankmememachine on 3/7/2023 in #help
❔ How to get specific fields from a Http GET request
to choose
208 replies