Skip to content

Instantly share code, notes, and snippets.

@hdml
hdml / nut_osx.txt
Last active March 28, 2024 06:55 — forked from 2b/nut_osx.txt
Network UPS Tools on macOS High Sierra (netclient)
#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/
@lunny
lunny / diskinfo.go
Created March 28, 2014 08:59
Disk Info for Golang
package main
import (
"fmt"
"syscall"
)
type DiskStatus struct {
All uint64 `json:"all"`
Used uint64 `json:"used"`
@yujiang
yujiang / gist:6080628
Last active December 20, 2015 05:48
reuse Lua's coroutine
--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
anonymous
anonymous / hash.php
Created March 27, 2013 07:23
<?php
/**
* 加密 hash,生成发送给用户的 hash 字符串
*
* @param array $hash_data
* @param string $hash_key
* @return string
*/
function encode_hash($hash_data, $hash_key = false)
@TooTallNate
TooTallNate / emitLines.js
Created February 10, 2012 01:11
Make any ReadableStream emit "line" events
/**
* 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) {