language-agnostic

Convert chinese characters to hanyu pinyin

若如初见. 提交于 2020-01-01 03:19:10
问题 How to convert from chinese characters to hanyu pinyin? E.g. 你 --> Nǐ 马 --> Mǎ More Info: Either accents or numerical forms of hanyu pinyin are acceptable, the numerical form being my preference. A Java library is preferred, however, a library in another language that can be put in a wrapper is also OK. I would like anyone who has personally used such a library before to recommend or comment on it, in terms of its quality/ reliabilitty. 回答1: The problem of converting hanzi to pinyin is a

Storage of many log files

北城以北 提交于 2020-01-01 02:40:14
问题 I have a system which is receiving log files from different places through http (>10k producers, 10 logs per day, ~100 lines of text each). I would like to store them to be able to compute misc. statistics over them nightly , export them (ordered by date of arrival or first line content) ... My question is : what's the best way to store them ? Flat text files (with proper locking), one file per uploaded file, one directory per day/producer Flat text files, one (big) file per day for all

How do I find the center of a number of geographic points?

丶灬走出姿态 提交于 2020-01-01 01:33:26
问题 If I have a series of points as longitude and latitude, how would I calculate the center of all of those points? 回答1: Geomidpoint covers 3 different methods for calculating this. 回答2: Several people have answered to take the mean of the latitudes and longitudes. This is sort of the right idea, but means are more complicated on the sphere. The latitude/longitude representation is essentially artificial and has discontinuities (at the poles, and opposite the prime meridian if you aren't careful

Crappy Random Number Generator

谁都会走 提交于 2019-12-31 22:41:09
问题 This may sound like an odd question, but where can I find a random number generator that works in C or C++ that is not very good? Context: I'm creating some tree graph plotting software and testing it by using multi-digit random numbers (so each digit becomes a node in the tree). The random number generator I've been using - which is the one that comes with the GNU C++ compiler - gives me a nice spread of values. That's good, but I want to see how the table looks when the numbers clump

What is a Calendar Queue?

霸气de小男生 提交于 2019-12-31 21:36:11
问题 I am working on a building a discrete event simulator. Wikipedia mentioned that there are several general purpose priority queues that are good for use in DES's. Specifically, it mentions that a Calendar Queue is a good structure. I found one pdf (from 1988) that mentions Calendar Queues, but for the most part I can't find anything else out about them. Would someone mind explaining what Calendar Queue's are, how they're used, and where I might find a sample implementation? 回答1: A Google

What is a Calendar Queue?

北城余情 提交于 2019-12-31 21:35:49
问题 I am working on a building a discrete event simulator. Wikipedia mentioned that there are several general purpose priority queues that are good for use in DES's. Specifically, it mentions that a Calendar Queue is a good structure. I found one pdf (from 1988) that mentions Calendar Queues, but for the most part I can't find anything else out about them. Would someone mind explaining what Calendar Queue's are, how they're used, and where I might find a sample implementation? 回答1: A Google

Should I throw on null parameters in private/internal methods?

女生的网名这么多〃 提交于 2019-12-31 19:54:01
问题 I'm writing a library that has several public classes and methods, as well as several private or internal classes and methods that the library itself uses. In the public methods I have a null check and a throw like this: public int DoSomething(int number) { if (number == null) { throw new ArgumentNullException(nameof(number)); } } But then this got me thinking, to what level should I be adding parameter null checks to methods? Do I also start adding them to private methods? Should I only do

Should I throw on null parameters in private/internal methods?

笑着哭i 提交于 2019-12-31 19:52:26
问题 I'm writing a library that has several public classes and methods, as well as several private or internal classes and methods that the library itself uses. In the public methods I have a null check and a throw like this: public int DoSomething(int number) { if (number == null) { throw new ArgumentNullException(nameof(number)); } } But then this got me thinking, to what level should I be adding parameter null checks to methods? Do I also start adding them to private methods? Should I only do

Should I throw on null parameters in private/internal methods?

我的梦境 提交于 2019-12-31 19:52:05
问题 I'm writing a library that has several public classes and methods, as well as several private or internal classes and methods that the library itself uses. In the public methods I have a null check and a throw like this: public int DoSomething(int number) { if (number == null) { throw new ArgumentNullException(nameof(number)); } } But then this got me thinking, to what level should I be adding parameter null checks to methods? Do I also start adding them to private methods? Should I only do

For what kind of problems do you write a DSL?

痴心易碎 提交于 2019-12-31 19:22:06
问题 I'm just curious about Domain-Specific Languages. I have seen them several times in articles, and it seems that they can be used outside assurance or bank data definition problems. So I come to SO to have some concrete input. Did you ever use a DSL? Write one. If yes, what's it feel like? Do you think one of your projects could be better (more productive, more maintainable, ...) with a DSL? Edit : I'm sorry to put this after, but i was meanning a specific DSL that you wrote yourself. It's