Returns a slice of n random integers in the specified range.

Use make() to create an appropriate slice.
Use range to iterate over the slice, rand.Intn() to generate random numbers between 0 and the distance between min and max, adding min to them.

继续阅读 30秒学会 Golang 片段 – RandIntSliceInRange

Removes elements from the end of a list until the passed function returns true and returns the remaining elements.

Use List.lastIndexWhere() with the test function to find the last element that returns true.
Return an empty array if there are no matching elements, otherwise use List.sublist() to return the remaining elements.

继续阅读 30秒学会 Dart 片段 – dropRightWhile

Gets the day of the year from a Date object.

Use new Date() and Date.prototype.getFullYear() to get the first day of the year as a Date object, subtract it from the provided date and divide with the milliseconds in each day to get the result.
Use Math.floor() to appropriately round the resulting day count to an integer.

继续阅读 30秒学会 JavaScript 片段 – dayOfYear