This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ### | |
| ### my-script — does one thing well | |
| ### | |
| ### Usage: | |
| ### my-script <input> <output> | |
| ### | |
| ### Options: | |
| ### <input> Input file to read. | |
| ### <output> Output file to write. Use '-' for stdout. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "errors" | |
| "fmt" | |
| "sync" | |
| "time" | |
| ) | |
| const ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static inline bool | |
| is_pow_of_2(uint32_t x) { | |
| return !(x & (x-1)); | |
| } | |
| static inline uint32_t | |
| next_pow_of_2(uint32_t x) { | |
| if ( is_pow_of_2(x) ) | |
| return x; | |
| x |= x>>1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 一个方便的 hash 函数应该散列的比较开,计算速度跟字符串长度关系不大,又不能只计算字符串的开头或末尾。这里的算法是从 Lua 中看来的。 | |
| unsigned long hash(const char *name,size_t len) | |
| { | |
| unsigned long h=(unsigned long)len; | |
| size_t step = (len>>5)+1; | |
| for (size_t i=len; i>=step; i-=step) | |
| h = h ^ ((h<<5)+(h>>2)+(unsigned long)name[i-1]); | |
| return h; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| union luai_Cast { double l_d; long l_l; }; | |
| #define lua_number2int(i,d) \ | |
| { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } |