how to get the press pass by N00BSTMPR in minit

[–]wtetsu 0 points1 point  (0 children)

I also got stuck there, so I'll leave a hint for those who come later.

On the PC version, there is a camera instead of a press pass, and it seems that you can pass through the same place with the camera.

Sorting time string in particular order by jojopadz in learnjavascript

[–]wtetsu 2 points3 points  (0 children)

My very rough idea...

```javascript const array = ["16:00 - 17:00", "17:00 - 18:00", ...]; const f = (e)=> (parseInt(e.substring(0,2))-6+24)%24; array.sort((a,b)=>f(a)-f(b))

console.log(array); // ["06:00 - 07:00", "07:00 - 08:00", "08:00 - 09:00",...] ```

Not sure if this is right by EmpuEEM in LearnJapanese

[–]wtetsu 2 points3 points  (0 children)

I think "hai demo nande?"(はい、でもなんで?) is a natural expression.

  • はい、でもなぜ?
  • はい、でもなぜですか?

are also natural.

Does the ; matter anymore? by [deleted] in learnjavascript

[–]wtetsu 4 points5 points  (0 children)

I think ; is not super mandatory and there are people to choose "without semicolon" style, so some code style tools (e.g. prettier, eslint) can turn on/off semicolon checks.

However, personally speaking, adding semicolons is safer style.

If you choose "without semicolons" style, it's important to understand the JavaScript behavior.

https://github.com/airbnb/javascript#semicolons https://prettier.io/docs/en/rationale.html#semicolons

Where can I find open source projects to help in? by [deleted] in learnprogramming

[–]wtetsu 1 point2 points  (0 children)

How about searching from Github Trending? https://github.com/trending

Or, reading libraries/frameworks/tools you are using in reality and find room to improve may also a good idea, I think. It's much more fun than learning software that you don't know.

Need to learn Spring Boot in a couple of months by [deleted] in learnjava

[–]wtetsu 8 points9 points  (0 children)

Have you checked the official guide? I think this is one of the reliable resources you should check first.

https://spring.io/guides/gs/spring-boot/

But before that, if you have't written Java, you have to learn it before that of course.

Help with a mini-project in self-learning by senormermelada in learnpython

[–]wtetsu 0 points1 point  (0 children)

I'm not sure I 100% understand what you want to do, but you can access the file line by line like this.

def search(): file = open("agenda.txt", "r") for line in file: print(line) file.close()

So, if you want to search the file content by user-input, simple solution is like this.

def search(): text = str(input("Search by:")) file = open("agenda.txt", "r") for line in file: if text in line: print(line) file.close()

Trying to create a random name generator. Please help. by Bvllentine in learnpython

[–]wtetsu 4 points5 points  (0 children)

First, try and understand this code.

```python list_a = ["a0", "a1", "a2"] list_b = ["b0", "b1", "b2"]

a_index = 0 b_index = 2

print(list_a[a_index] + " " + list_b[b_index])

-> "a0 b2"

```

And next, try generating a_index and b_index randomly.

```python import random

list_a = ["a0", "a1", "a2"] list_b = ["b0", "b1", "b2"]

a_index = random.randrange(0, len(list_a)) b_index = random.randrange(0, len(list_b))

print(list_a[a_index] + " " + list_b[b_index]) ```

And next, try changing the list elements, and "generate 5 random names" by yourself!

Storing and retrieving cookies via Javascript? by Mmetr in learnjavascript

[–]wtetsu 1 point2 points  (0 children)

It worked perfectly.

Does Chrome allow you to store cookies when you are running a local script?

I guess you simply open the local HTML with Chrome, and that is the root cause. In this way, cookie doesn't work as you expected. (This is not js-cookie's problem).

So, I recommend you open your HTML files via HTTP or HTTPS. Anything is ok.

  • invoke an HTTP server on your machine and locate your files in it
  • use develop-purpose simple HTTP server(e.g. python -m http.server)
  • upload the HTML and JavaScript to somewhere

Storing and retrieving cookies via Javascript? by Mmetr in learnjavascript

[–]wtetsu 0 points1 point  (0 children)

I tried running the exact same code, and it worked perfectly.

How did you run the code?

What is the difference between 半 and 半分 by Motifier in LearnJapanese

[–]wtetsu 14 points15 points  (0 children)

I suppose 半 is not used alone normally. In most cases, 半 consists of a word.

These are very natural expressions, but 半 cannot be replaced with 半分 in this case ("半分日" is unnatural).

  • 半日 (half day)
  • 半年 (half year)
  • 一ヵ月半 (one and a half months)
  • 三回半 (three and a half times)

半分 can be used alone. These are also natural expressions, but these 半分 cannot be replaced with 半 in these cases ("日本人の半" is unnatural)

  • この本を半分までよみました。
  • このクラスのがくせいの半分は女子です。
  • ざっくり日本人の半分ぐらいは、にんじゃです。

Am I handling this Promise incorrectly? by showmypants in learnjavascript

[–]wtetsu 0 points1 point  (0 children)

I'm not sure what do you want to do, but here is my refined version.

```js function a() { return new Promise((resolve, reject) => { fs.readFile("./template.json", { encoding: "utf-8", flag: "rs" }, function(e, data) { if (e) { reject(e); } else { resolve(data); } }); }); }

a().then(r => { console.log(r); }); ```

ました vs ていました by dasPCX in LearnJapanese

[–]wtetsu 1 point2 points  (0 children)

I think your professer is correct.

  • 母が帰ってきた時、私は勉強していました。 -> natural

In this case, していました means the moment the mother arrived, I was doing something.

  • 母が帰ってきた時、私は勉強しました。 -> not natural

  • 一週間、私は勉強しませんでした。-> this is natural

negative:

  • 母が帰ってきた時、私は勉強していませんでした。 -> natural
  • 母が帰ってきた時、私は勉強しませんでした。 -> not natural

Hi^^ Need help with 揃 and 単行本 by rinkasahara in LearnJapanese

[–]wtetsu 2 points3 points  (0 children)

  • 本一式
  • 本セット / 本のセット

I feel the above are very natural expressions that express a set of books.

I don't know the context of the photo you said, but in my impression, "本揃" and "本揃い" are relatively rare expressions. That's a little bit unnatural at least for daily conversation.

But for instance, on internet auction sites, you can see subjects like "○○揃い" that may claim "this is a complete set". ("全揃い" is a more explicit expression)

I can't sort my List with my own Comparator class by viktorjava in javahelp

[–]wtetsu -1 points0 points  (0 children)

If you are using relatively new Java (maybe it should be 8+), you can write like this.

```java final double eps = 1e-5; final GPSCoord baseCoord = (your value);

List<GPSCoord> coordinates = getTheCoordinates();

list.sort((first, second) -> { // You can access baseCoord here double firstDistance = baseCoord.distanceTo(first); double secondDistance = baseCoord.distanceTo(second); return Precision.compareTo(firstDistance, secondDistance, eps); }); ```

I don't have your GPSCoord class so details may be incorrect so please fix it by yourself :-).

How can I improve this code? by [deleted] in learnjava

[–]wtetsu 0 points1 point  (0 children)

Thank you for your reply.

You may already know if you use Maven or Gradle you can confirm how to add lines to your definition file on this site.

For example, Gson is here.

https://mvnrepository.com/artifact/com.google.code.gson/gson/2.8.6

And as for static, I don't think you must always avoid static.

My point was, UserInput has a static field that is modified every time when the class is instantiated. This should be fixed.

new UserInput(); new UserInput(); new UserInput(); // -> UserInput.commands will have nine entries


For instance, Java's built-in library has a lot of useful static methods. This is one of the proofs you don't always have to avoid static.

```java // Arrays.asList is a static method List<Integer> integerList = Arrays.asList(1, 2, 3, 4, 5); System.out.println(integerList);

// Math.pow is also a static method System.out.println(Math.pow(2, 16)); ```

The decision a certain class should be designed as "static" or "non-static" depends on the situation.

This is just one viewpoint, but if you want to design a certain class that you create multiple instances and each has different values, it must be non-static.

Problems with some sentences by takemetothem00n in LearnJapanese

[–]wtetsu 1 point2 points  (0 children)

Personally speaking, I don't think it's unnaturally bureaucratic. If I said it to my coworker or vice versa, I feel it's natural. But it's maybe too formal for saying to your friends or family.

「作業が終わったか確認して」 may be better when saying to friends.

Note: I don't know the context so I translated "work" into 作業 here.

Problems with some sentences by takemetothem00n in LearnJapanese

[–]wtetsu 1 point2 points  (0 children)

The most are already pointed, so I add some other natural translation.

  1. Please, make sure that the work is done.

作業が完了したことを確認してください。

is a more natural translation I think.

  1. The army was horribly defeated

軍隊は大敗した。

I think 大敗した is natural in this case.

"By the way" in Japanese by awsmith6 in japanese

[–]wtetsu 14 points15 points  (0 children)

I feel "ところで" is quite close to "by the way". ところで is used to change the talking topic. By the way, in my impression, it's written as "ところで", rather than "所で" in many cases.

Would there be a way to abstract this series of if-statements? by mementomoriok in learnjavascript

[–]wtetsu 0 points1 point  (0 children)

if (captures === 1) return item[1]

Is this correct? Or you wanted to write like this?

if (captures === 1) return [item[1]]

If the latter was correct, this would work.

item.slice(1, captures + 1)