This file contains 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
#install homebrew | |
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
#install network ups tools | |
brew update | |
brew install nut | |
#create directories and change permissions | |
sudo mkdir -p /var/state/ups/upssched/ | |
sudo chown -R `whoami`:nobody /var/state/ups | |
sudo chmod 775 /var/state/ups/ |
This file contains 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 ( | |
"fmt" | |
"syscall" | |
) | |
type DiskStatus struct { | |
All uint64 `json:"all"` | |
Used uint64 `json:"used"` |
This file contains 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
--coroutine pool | |
local freelist={}; | |
function find_free(f) | |
if #freelist > 0 then | |
local free = freelist[#freelist] | |
table.remove(freelist) | |
return {thread = free,func = f,status="create"} | |
end | |
end |
This file contains 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
<?php | |
/** | |
* 加密 hash,生成发送给用户的 hash 字符串 | |
* | |
* @param array $hash_data | |
* @param string $hash_key | |
* @return string | |
*/ | |
function encode_hash($hash_data, $hash_key = false) |
This file contains 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
/** | |
* A quick little thingy that takes a Stream instance and makes | |
* it emit 'line' events when a newline is encountered. | |
* | |
* Usage: | |
* ‾‾‾‾‾ | |
* emitLines(process.stdin) | |
* process.stdin.resume() | |
* process.stdin.setEncoding('utf8') | |
* process.stdin.on('line', function (line) { |