Twitter图像编码挑战[关闭]

Easter79
• 阅读 675

问题:

If a picture's worth 1000 words, how much of a picture can you fit in 140 characters? 如果一张图片价值1000字,你可以在140个字符中放入多少图片?

Note : That's it folks! 注意 :那就是大家! Bounty deadline is here, and after some tough deliberation, I have decided that Boojum's entry just barely edged out Sam Hocevar's . 赏金的最后期限就在这里,经过一番艰难的考虑后,我认为Boojum的进入只是勉强淘汰Sam Hocevar的 I will post more detailed notes once I've had a chance to write them up. 一旦我有机会写下来,我会发布更详细的笔记。 Of course, everyone should feel free to continue to submit solutions and improve solutions for people to vote on. 当然,每个人都应该随时继续提交解决方案并改进人们投票的解决方案。 Thank you to everyone who submitted and entry; 感谢所有提交和参赛的人; I enjoyed all of them. 我很喜欢他们。 This has been a lot of fun for me to run, and I hope it's been fun for both the entrants and the spectators. 这对我来说非常有趣,我希望这对参赛者和观众来说都很有趣。

I came across this interesting post about trying to compress images into a Twitter comment, and lots of people in that thread (and a thread on Reddit ) had suggestions about different ways you could do it. 我遇到了一篇关于尝试将图像压缩成Twitter评论的有趣帖子 ,该线程中的很多人(以及Reddit上的一个帖子 )都提出了有关不同方法的建议。 So, I figure it would make a good coding challenge; 所以,我认为这将是一个很好的编码挑战; let people put their money where their mouth is, and show how their ideas about encoding can lead to more detail in the limited space that you have available. 让人们将钱放在嘴边,并展示他们对编码的看法如何在有限的空间中提供更多细节。

I challenge you to come up with a general purpose system for encoding images into 140 character Twitter messages, and decoding them into an image again. 我挑战你想出一个通用系统,用于将图像编码成140个字符的Twitter消息,并将它们再次解码为图像。 You can use Unicode characters, so you get more than 8 bits per character. 您可以使用Unicode字符,因此每个字符的字符数超过8位。 Even allowing for Unicode characters, however, you will need to compress images into a very small amount of space; 但是,即使允许使用Unicode字符,也需要将图像压缩到非常小的空间内; this will certainly be a lossy compression, and so there will have to be subjective judgements about how good each result looks. 这肯定会是一种有损压缩,因此必须对每种结果的好看进行主观判断。

Here is the result that the original author, Quasimondo , got from his encoding (image is licensed under a Creative Commons Attribution-Noncommercial license ): 以下是原作者Quasimondo从他的编码中获得的结果(图片根据知识共享署名 - 非商业许可证授权 ): Twitter图像编码挑战[关闭]

Can you do better? 你能做得更好吗?

Rules 规则

  1. Your program must have two modes: encoding and decoding . 您的程序必须有两种模式: 编码解码** 。**

  2. When encoding : 编码时

    1. Your program must take as input a graphic in any reasonable raster graphic format of your choice. 您的程序必须以您选择的任何合理光栅图形格式输入图形作为输入。 We'll say that any raster format supported by ImageMagick counts as reasonable. 我们会说ImageMagick支持的任何栅格格式都算合理。
    2. Your program must output a message which can be represented in 140 or fewer Unicode code points; 您的程序必须输出一条消息,该消息可以用140个或更少的Unicode代码点表示; 140 code points in the range U+0000U+10FFFF , excluding non-characters ( U+FFFE , U+FFFF , U+ n FFFE , U+ n FFFF where n is 110 hexadecimal, and the range U+FDD0U+FDEF ) and surrogate code points ( U+D800U+DFFF ). 140个代码点,范围为U+0000 - U+10FFFF ,不包括非字符( U+FFFEU+FFFFU+ n FFFEU+ n FFFF ,其中_n_为1 - 10十六进制,范围为U+FDD0 - U+FDEF )和代理代码点( U+D800 - U+DFFF )。 It may be output in any reasonable encoding of your choice; 它可以以您选择的任何合理编码输出; any encoding supported by GNU iconv will be considered reasonable, and your platform native encoding or locale encoding would likely be a good choice. GNU iconv支持的任何编码都被认为是合理的,您的平台本机编码或区域设置编码可能是一个不错的选择。 See Unicode notes below for more details. 有关详细信息,请参阅下面的Unicode注释****
  3. When decoding : 解码时

    1. Your program should take as input the output of your encoding mode. 您的程序应该将编码模式的输出作为输入。
    2. Your program must output an image in any reasonable format of your choice, as defined above, though for output vector formats are OK as well. 您的程序必须以您选择的任何合理格式输出图像,如上所述,但输出矢量格式也可以。
    3. The image output should be an approximation of the input image; 图像输出应该是输入图像的近似值; the closer you can get to the input image, the better. 越接近输入图像越好。
    4. The decoding process may have no access to any other output of the encoding process other than the output specified above; 除了上面指定的输出之外,解码过程可能无法访问编码过程的任何其他输出; that is, you can't upload the image somewhere and output the URL for the decoding process to download, or anything silly like that. 也就是说,你不能在某处上传图像并输出用于下载的解码过程的URL,或任何类似的傻事。
  4. For the sake of consistency in user interface, your program must behave as follows: 为了用户界面的一致性,您的程序必须按如下方式运行:

    1. Your program must be a script that can be set to executable on a platform with the appropriate interpreter, or a program that can be compiled into an executable. 您的程序必须是可以在具有相应解释器的平台上设置为可执行的脚本,或者可以编译为可执行文件的程序。

    2. Your program must take as its first argument either encode or decode to set the mode. 您的程序必须将第一个参数作为encodedecode来设置模式。

    3. Your program must take input in one or more of the following ways (if you implement the one that takes file names, you may also read and write from stdin and stdout if file names are missing): 您的程序必须通过以下一种或多种方式获取输入(如果您实现了带文件名的方法,如果文件名丢失,您也可以从stdin和stdout读取和写入):

      1. Take input from standard in and produce output on standard out. 从标准输入获取输入并在标准输出上产生输出。

        my-program encode <input.png >output.txt my-program decode <output.txt >output.png
        
      2. Take input from a file named in the second argument, and produce output in the file named in the third. 从第二个参数中指定的文件中获取输入,并在第三个参数中指定的文件中生成输出。

        my-program encode input.png output.txt my-program decode output.txt output.png
        
  5. For your solution, please post: 对于您的解决方案,请发布:

    1. Your code, in full, and/or a link to it hosted elsewhere (if it's very long, or requires many files to compile, or something). 你的代码,完整的,和/或在其他地方托管的链接(如果它很长,或者需要很多文件来编译,或者其他东西)。
    2. An explanation of how it works, if it's not immediately obvious from the code or if the code is long and people will be interested in a summary. 解释它是如何工作的,如果代码中不是很明显,或者代码很长,人们会对摘要感兴趣。
    3. An example image, with the original image, the text it compresses down to, and the decoded image. 示例图像,包含原始图像,压缩到的文本以及解码图像。
    4. If you are building on an idea that someone else had, please attribute them. 如果您的想法是基于其他人的想法,请归因于他们。 It's OK to try to do a refinement of someone else's idea, but you must attribute them. 尝试改进别人的想法是可以的,但你必须归因于他们。

Guidelines 方针

These are basically rules that may be broken, suggestions, or scoring criteria: 这些基本上是可能被破坏的规则,建议或评分标准:

  1. Aesthetics are important. 美学很重要。 I'll be judging, and suggest that other people judge, based on: 我将评判,并建议其他人判断,基于:
    1. How good the output image looks, and how much it looks like the original. 输出图像看起来有多好,它看起来像原始图像。
    2. How nice the text looks. 文字看起来有多好看。 Completely random gobbledigook is OK if you have a really clever compression scheme, but I also want to see answers that turn images into mutli-lingual poems, or something clever like that. 如果你有一个非常聪明的压缩方案,完全随机的gobbledigook是好的,但我也希望看到将图像变成多语言的答案,或者像这样聪明的东西。 Note that the author of the original solution decided to use only Chinese characters, since it looked nicer that way. 请注意,原始解决方案的作者决定只使用中文字符,因为它看起来更好。
    3. Interesting code and clever algorithms are always good. 有趣的代码和聪明的算法总是很好。 I like short, to the point, and clear code, but really clever complicated algorithms are OK too as long as they produce good results. 我喜欢简短,重点和清晰的代码,但只要它们产生良好的结果,真正聪明的复杂算法也可以。
  2. Speed is also important, though not as important as how good a job compressing the image you do. 速度也很重要,但不如压缩你做的图像的工作有多重要。 I'd rather have a program that can convert an image in a tenth of a second than something that will be running genetic algorithms for days on end. 我宁愿有一个程序可以在十分之一秒内转换图像,而不是几天运行遗传算法的图像。
  3. I will prefer shorter solutions to longer ones, as long as they are reasonably comparable in quality; 我会更喜欢较短的解决方案,只要它们在质量上具有相当的可比性; conciseness is a virtue. 简洁是一种美德。
  4. Your program should be implemented in a language that has a freely-available implementation on Mac OS X, Linux, or Windows. 您的程序应该使用在Mac OS X,Linux或Windows上具有可自由实现的实现的语言来实现。 I'd like to be able to run the programs, but if you have a great solution that only runs under MATLAB or something, that's fine. 我希望能够运行这些程序,但如果你有一个只能在MATLAB下运行的优秀解决方案,那很好。
  5. Your program should be as general as possible; 你的计划应该尽可能一般; it should work for as many different images as possible, though some may produce better results than others. 它应该适用于尽可能多的不同图像,尽管有些图像可能比其他图像产生更好的结果。 In particular: 特别是:
    1. Having a few images built into the program that it matches and writes a reference to, and then produces the matching image upon decoding, is fairly lame and will only cover a few images. 将一些内置于程序中的图像与其匹配并写入引用,然后在解码时生成匹配图像,相当蹩脚,并且仅覆盖少量图像。
    2. A program that can take images of simple, flat, geometric shapes and decompose them into some vector primitive is pretty nifty, but if it fails on images beyond a certain complexity it is probably insufficiently general. 一个可以拍摄简单,平面,几何形状的图像并将它们分解成一些矢量图形的程序非常漂亮,但是如果它在超出一定复杂度的图像上失败则可能不够通用。
    3. A program that can only take images of a particular fixed aspect ratio but does a good job with them would also be OK, but not ideal. 一个程序只能拍摄特定固定宽高比的图像,但能很好地使用它们也可以,但不理想。
    4. You may find that a black and white image can get more information into a smaller space than a color image. 您可能会发现黑白图像可以在比彩色图像更小的空间中获得更多信息。 On the other hand, that may limit the types of image it's applicable to; 另一方面,这可能会限制它适用的图像类型; faces come out fine in black and white, but abstract designs may not fare so well. 黑色和白色的面孔很好,但抽象的设计可能不会那么好。
    5. It is perfectly fine if the output image is smaller than the input, while being roughly the same proportion. 如果输出图像小于输入,则完全没有问题,而大致相同的比例。 It's OK if you have to scale the image up to compare it to the original; 如果您必须将图像缩放以将其与原始图像进行比较,则可以。 what's important is how it looks. 重要的是它的外观。
  6. Your program should produce output that could actually go through Twitter and come out unscathed. 你的程序应该产生的输出实际上可以通过Twitter并且毫发无伤。 This is only a guideline rather than a rule, since I couldn't find any documentation on the precise set of characters supported, but you should probably avoid control characters, funky invisible combining characters, private use characters, and the like. 这只是一个指导而不是规则,因为我找不到任何支持的精确字符集的文档,但你应该避免控制字符,时髦的隐形组合字符,私人使用字符等。

Scoring rubric 得分量规

As a general guide to how I will be ranking solutions when choosing my accepted solution, lets say that I'll probably be evaluating solutions on a 25 point scale (this is very rough, and I won't be scoring anything directly, just using this as a basic guideline): 作为我在选择我接受的解决方案时如何对解决方案进行排名的一般指南,让我说我可能会以25分的比例评估解决方案(这非常粗糙,我不会直接评分任何东西,只是使用这是一个基本准则):

  • 15 points for how well the encoding scheme reproduces a wide range of input images. *15点表示编码方案如何再现各种输入图像。* This is a subjective, aesthetic judgement 这是一种主观的审美判断
    • 0 means that it doesn't work at all, it gives the same image back every time, or something 0表示它根本不起作用,每次都会返回相同的图像,或者其他东西
    • 5 means that it can encode a few images, though the decoded version looks ugly and it may not work at all on more complicated images 5意味着它可以编码一些图像,虽然解码版本看起来很丑,但在更复杂的图像上它可能根本不起作用
    • 10 means that it works on a wide range of images, and produces pleasant looking images which may occasionally be distinguishable 10意味着它适用于各种图像,并产生令人愉悦的图像,偶尔可以区分
    • 15 means that it produces perfect replicas of some images, and even for larger and more complex images, gives something that is recognizable. 15意味着它可以生成一些图像的完美复制品,即使对于更大和更复杂的图像,它也能提供可识别的东西。 Or, perhaps it does not make images that are quite recognizable, but produces beautiful images that are clearly derived from the original. 或者,它可能不会使图像具有很强的识别性,但会产生明显来自原始图像的精美图像。
  • 3 points for clever use of the Unicode character set 聪明地使用Unicode字符集3分****
    • 0 points for simply using the entire set of allowed characters 简单地使用整组允许的字符为0分
    • 1 point for using a limited set of characters that are safe for transfer over Twitter or in a wider variety of situations 1点使用一组有限的字符,这些字符可以安全地通过Twitter或更广泛的情况进行传输
    • 2 points for using a thematic subset of characters, such as only Han ideographs or only right-to-left characters 使用主题字符子集的2分,例如仅汉字表意文字或仅从右到左字符
    • 3 points for doing something really neat, like generating readable text or using characters that look like the image in question 做一些非常整洁的事情需要3分,例如生成可读文本或使用看起来像有问题的图像的字符
  • 3 points for clever algorithmic approaches and code style 聪明的算法方法和代码风格有3个点****
    • 0 points for something that is 1000 lines of code only to scale the image down, treat it as 1 bit per pixel, and base64 encode that 只有1000行代码的0分才能缩小图像,将其视为每像素1位,而base64编码为
    • 1 point for something that uses a standard encoding technique and is well written and brief 对于使用标准编码技术并且写得很好并且简短的东西的1分
    • 2 points for something that introduces a relatively novel encoding technique, or that is surprisingly short and clean 对于引入相对新颖的编码技术或者令人惊讶的短而干净的东西的2分
    • 3 points for a one liner that actually produces good results, or something that breaks new ground in graphics encoding (if this seems like a low number of points for breaking new ground, remember that a result this good will likely have a high score for aesthetics as well) 实际上可以产生良好效果的一个衬垫有3个点,或者在图形编码方面突破新领域的东西(如果这看起来像是一个很少的分数用于突破新的领域,请记住,这个优点可能会对美学产生高分以及)
  • 2 points for speed. *2分的速度。* All else being equal, faster is better, but the above criteria are all more important than speed 在其他条件相同的情况下,速度越快越好,但上述标准都比速度更重要
  • 1 point for running on free (open source) software, because I prefer free software (note that C# will still be eligible for this point as long as it runs on Mono, likewise MATLAB code would be eligible if it runs on GNU Octave) 在免费(开源)软件上运行1分** ,因为我更喜欢免费软件(请注意,只要它在Mono上运行,C#仍然符合此要求,如果在GNU Octave上运行,MATLAB代码也是合格的)**
  • 1 point for actually following all of the rules. 实际遵守所有规则的1分** 。** These rules have gotten a bit big and complicated, so I'll probably accept otherwise good answers that get one small detail wrong, but I will give an extra point to any solution that does actually follow all of the rules 这些规则变得有点大而复杂,所以我可能会接受其他好的答案,这会让一个小细节错误,但我会给任何实际遵循所有规则的解决方案额外的一点

Reference images 参考图片

Some folks have asked for some reference images. 有些人要求提供一些参考图像。 Here are a few reference images that you can try; 以下是一些您可以尝试的参考图像; smaller versions are embedded here, they all link to larger versions of the image if you need those: 这里嵌入了较小的版本,如果您需要,它们都链接到更大版本的图像:

Twitter图像编码挑战[关闭] Twitter图像编码挑战[关闭] Twitter图像编码挑战[关闭] Twitter图像编码挑战[关闭]

Prize

I am offering a 500 rep bounty (plus the 50 that StackOverflow kicks in) for the solution that I like the best, based on the above criteria. 根据上述标准,我提供了500个代表奖金** (加上StackOverflow推出的50个奖励 ),用于我最喜欢的解决方案。** Of course, I encourage everyone else to vote on their favorite solutions here as well. 当然,我也鼓励其他人在这里投票选出他们最喜欢的解决方案。

Note on deadline 关于截止日期的说明

This contest will run until the bounty runs out, about 6 PM on Saturday, May 30. I can't say the precise time it will end; 这场比赛将持续到赏金用完,即5月30日星期六下午6点左右。我不能说它将结束的确切时间; it may be anywhere from 5 to 7 PM. 它可能是从下午5点到7点。 I will guarantee that I'll look at all entries submitted by 2 PM, and I will do my best to look at all entries submitted by 4 PM; 我保证我会查看下午2点提交的所有参赛作品,我会尽力查看下午4点提交的所有参赛作品; if solutions are submitted after that, I may not have a chance to give them a fair look before I have to make my decision. 如果在此之后提交解决方案,我可能没有机会在我做出决定之前给他们一个公平的看法。 Also, the earlier you submit, the more chance you will have for voting to be able to help me pick the best solution, so try and submit earlier rather than right at the deadline. 此外,您提交的越早,您投票的机会就越大,可以帮助我选择最佳解决方案,因此请尽早提交,而不是在截止日期前提交。

Unicode notes Unicode注释

There has also been some confusion on exactly what Unicode characters are allowed. 究竟是什么允许Unicode字符也存在一些混淆。 The range of possible Unicode code points is U+0000 to U+10FFFF . 可能的Unicode代码点范围是U+0000U+10FFFF There are some code points which are never valid to use as Unicode characters in any open interchange of data; 在任何开放的数据交换中,有一些代码点永远无法用作Unicode字符; these are the noncharacters and the surrogate code points . 这些都是noncharacters代理代码点** 。** Noncharacters are defined in the Unidode Standard 5.1.0 section 16.7 as the values U+FFFE , U+FFFF , U+ n FFFE , U+ n FFFF where n is 110 hexadecimal, and the range U+FDD0U+FDEF . Noncharacters在所定义的Unidode标准5.1.0节16.7为值U+FFFEU+FFFFU+ Ñ FFFEU+ Ñ FFFF ,其中_n_为1 - 10十六进制和范围U+FDD0 - U+FDEF These values are intended to be used for application-specific internal usage, and conforming applications may strip these characters out of text processed by them. 这些值旨在用于特定于应用程序的内部使用,并且符合要求的应用程序可能会将这些字符从它们处理的文本中删除。 Surrogate code points, defined in the Unicode Standard 5.1.0 section 3.8 as U+D800U+DFFF , are used for encoding characters beyond the Basic Multilingual Plane in UTF-16; 代理点代码点在Unicode标准5.1.0第3.8节中定义为U+D800 - U+DFFF ,用于编码UTF-16中基本多语言平面之外的字符; thus, it is impossible to represent these code points directly in the UTF-16 encoding, and it is invalid to encode them in any other encoding. 因此,不可能直接在UTF-16编码中表示这些代码点,并且在任何其他编码中对它们进行编码是无效的。 Thus, for the purpose of this contest, I will allow any program which encodes images into a sequence of no more than 140 Unicode code points from the range U+0000U+10FFFF , excluding all noncharacters and surrogate pairs as defined above. 因此,为了本次比赛的目的,我将允许任何编码图像的程序从U+0000 - U+10FFFF范围内不超过140个Unicode代码点的序列,不包括上面定义的所有非字符和代理对。

I will prefer solutions that use only assigned characters, and even better ones that use clever subsets of assigned characters or do something interesting with the character set they use. 我_更喜欢_只使用指定字符的解决方案,甚至更_喜欢_使用指定字符的聪明子集或使用他们使用的字符集做一些有趣事情的解决方案。 For a list of assigned characters, see the Unicode Character Database ; 有关指定字符的列表,请参阅Unicode字符数据库 ; note that some characters are listed directly, while some are listed only as the start and end of a range. 请注意,某些字符是直接列出的,而有些字符仅列为范围的开头和结尾。 Also note that surrogate code points are listed in the database, but forbidden as mentioned above. 另请注意,代理代码点列在数据库中,但如上所述是禁止的。 If you would like to take advantage of certain properties of characters for making the text you output more interesting, there are a variety of databases of character information available, such as a list of named code blocks and various character properties . 如果您希望利用字符的某些属性来使输出的文本更有趣,则可以使用各种字符信息数据库 ,例如命名代码块列表各种字符属性

Since Twitter does not specify the exact character set they support, I will be lenient about solutions which do not actually work with Twitter because certain characters count extra or certain characters are stripped. 由于Twitter没有指定他们支持的确切字符集,因此我会对那些实际上不适用于Twitter的解决方案感到宽容,因为某些字符会计算额外的或某些字符被剥离。 It is preferred but not required that all encoded outputs should be able to be transferred unharmed via Twitter or another microblogging service such as identi.ca . 优选但不要求所有编码输出应该能够通过Twitter或其他微博服务(例如identi.ca)无损地传输。 I have seen some documentation stating that Twitter entity-encodes <, >, and &, and thus counts those as 4, 4, and 5 characters respectively, but I have not tested that out myself, and their JavaScript character counter doesn't seem to count them that way. 我已经看到一些文档声明Twitter实体编码<,>和&,因此分别计算为4个,4个和5个字符,但我没有自己测试过,他们的JavaScript字符计数器似乎没有以那种方式来统计他们。

  • The definition of valid Unicode characters in the rules is a bit complicated. 规则中有效Unicode字符的定义有点复杂。 Choosing a single block of characters, such as CJK Unified Ideographs (U+4E00–U+9FCF) may be easier. 选择单个字符块,例如CJK统一表意文字(U + 4E00-U + 9FCF)可能更容易。
  • You may use existing image libraries, like ImageMagick or Python Imaging Library , for your image manipulation. 您可以使用现有的图像库(如ImageMagickPython Imaging Library )进行图像处理。
  • If you need some help understanding the Unicode character set and its various encodings, see this quick guide or this detailed FAQ on UTF-8 in Linux and Unix . 如果您需要一些帮助来理解Unicode字符集及其各种编码,请参阅本快速指南有关Linux和Unix中UTF-8的详细常见问题解答
  • The earlier you get your solution in, the more time I (and other people voting) will have to look at it. 越早获得解决方案,我(以及其他人投票)就必须有更多时间来查看它。 You can edit your solution if you improve it; 如果您改进了解,您可以编辑解决方案; I'll base my bounty on the most recent version when I take my last look through the solutions. 当我最后一次查看解决方案时,我将以最新版本为基础。
  • If you want an easy image format to parse and write (and don't want to just use an existing format), I'd suggest using the PPM format . 如果你想要一个简单的图像格式来解析和写(并且不想只使用现有的格式),我建议使用PPM格式 It's a text based format that's very easy to work with, and you can use ImageMagick to convert to and from it. 它是一种基于文本的格式,非常易于使用,您可以使用ImageMagick进行转换。

解决方案:

参考一: https://stackoom.com/question/3jxL/Twitter图像编码挑战-关闭
参考二: https://oldbug.net/q/3jxL/Twitter-image-encoding-challenge-closed

点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
待兔 待兔
3个月前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Jacquelyn38 Jacquelyn38
3年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
Easter79 Easter79
3年前
Twitter的分布式自增ID算法snowflake (Java版)
概述分布式系统中,有一些需要使用全局唯一ID的场景,这种时候为了防止ID冲突可以使用36位的UUID,但是UUID有一些缺点,首先他相对比较长,另外UUID一般是无序的。有些时候我们希望能使用一种简单一些的ID,并且希望ID能够按照时间有序生成。而twitter的snowflake解决了这种需求,最初Twitter把存储系统从MySQL迁移
Wesley13 Wesley13
3年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
3年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Stella981 Stella981
3年前
Django中Admin中的一些参数配置
设置在列表中显示的字段,id为django模型默认的主键list_display('id','name','sex','profession','email','qq','phone','status','create_time')设置在列表可编辑字段list_editable
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
9个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这
Easter79
Easter79
Lv1
今生可爱与温柔,每一样都不能少。
文章
2.8k
粉丝
5
获赞
1.2k