Skip to content

Instantly share code, notes, and snippets.

@yunghoy
yunghoy / gist:a425f91824d26461bb2e3653bc56ebbf
Last active June 2, 2022 00:34
AMQP library (RabbitMQ) - async/await
alias babel-node='babel-node --presets stage-0'
------ RECV ------
// babel-node recv2.js "#"
// babel-node recv2.js "kern.*"
const amqp = require('amqplib');
const args = process.argv.slice(2);
if (args.length == 0) {
@mksoni88
mksoni88 / overridelog.js
Created September 15, 2015 04:10
Override console.log to print line number ( and filename ) (sometimes helpful in nodejs debugging)
_log = console.log;
global.console.log = function() {
var traceobj = new Error("").stack.split("\n")[2].split(":");
var file = traceobj[0].split(process.env.PWD + '/')[1];
var line = traceobj[1];
var new_args = [file + ":" + line + " >>"];
new_args.push.apply(new_args, arguments);
_log.apply(null, new_args);
};
@xcatliu
xcatliu / (已失效)中国区用户在开启 GitHub 两步验证中遇到的问题
Last active March 7, 2024 02:53
(已失效)中国区用户在开启 GitHub 两步验证中遇到的问题
2023.8.28
据多名网友回复,此方法已失效。
最新解决办法请参考此贴:[v2ex: 请问 github 的两步验证(two-factor authentication)大家是怎么做的?](https://www.v2ex.com/t/967533)
https://www.v2ex.com/t/967533
---
@afternoon
afternoon / rename_js_files.sh
Created February 15, 2014 18:04
Rename .js files to .ts
find app/src -name "*.js" -exec sh -c 'mv "$0" "${0%.js}.ts"' {} \;
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active May 5, 2024 18:31
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@d3noob
d3noob / .block
Last active October 21, 2023 12:33
D3.js tree diagram generated from external (JSON) data
license: mit
@asalant
asalant / connectWithRetry.js
Created November 17, 2012 01:24
Retry connecting to mongo if initial connect fails
var mongoose = require('mongoose')
var mongoUrl = "mongodb://localhost:27017/test"
var connectWithRetry = function() {
return mongoose.connect(mongoUrl, function(err) {
if (err) {
console.error('Failed to connect to mongo on startup - retrying in 5 sec', err);
setTimeout(connectWithRetry, 5000);
}
});