Skip to content

Instantly share code, notes, and snippets.

View jastisriradheshyam's full-sized avatar
🪀
((~~~))

Jasti Sri Radhe Shyam jastisriradheshyam

🪀
((~~~))
View GitHub Profile
@xlab
xlab / bytes_split.go
Last active April 4, 2022 17:21
Golang split byte slice in chunks sized by limit
func split(buf []byte, lim int) [][]byte {
var chunk []byte
chunks := make([][]byte, 0, len(buf)/lim+1)
for len(buf) >= lim {
chunk, buf = buf[:lim], buf[lim:]
chunks = append(chunks, chunk)
}
if len(buf) > 0 {
chunks = append(chunks, buf[:len(buf)])
}
@jastisriradheshyam
jastisriradheshyam / error_to_string.js
Last active April 14, 2020 11:17
Node JS, full error object to string
// node.js error object to string
const util = require('util')
var fullErrorObjectString = "";
try {
k++
} catch (error) {
console.log(util.inspect(error, false, null, false /* enable colors */))
fullErrorObjectString = util.inspect(error, false, null, false /* enable colors */).toString()
}