Skip to content

Instantly share code, notes, and snippets.

@mrlannigan
mrlannigan / .bashrc
Created December 17, 2012 16:01
Bash Prompt to Display SVN/GIT Current Branch
if [ -f ~/.bash_colors ]; then
. ~/.bash_colors
fi
PROMPT_COMMAND='RET=$?;'
function _returnLambda {
if [[ $RET = 0 ]]; then echo -e "${BGreen}"; else echo -e "${BRed}"; fi;
}
@mrlannigan
mrlannigan / bootstrap-ubuntu.sh
Created September 17, 2022 19:30 — forked from tyzbit/bootstrap-ubuntu.sh
bootstrap-ubuntu-server
#!/bin/bash
## Edit sudoers (add "NOPASSWD:" to the sudo line before ALL)
## Add optional: true to netplan and apply
# Install Docker
sudo apt-get update
sudo apt-get -y install \
apt-transport-https \
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Cinematic Bars</title>
<style>
body {
margin: 0;
padding: 0;
const list = document.getElementsByTagName('img')
for (let i = 0; i < list.length; i += 1) {
const img = list.item(i);
if (arraytomakered.includes(img.src)) {
img.style.border = '5px solid red';
}
}
@mrlannigan
mrlannigan / res.render.js
Created February 27, 2013 21:02
res.render Override Middleware
/**
* Override res.render to do any pre/post processing
*/
app.use(function(req, res, next) {
var render = res.render;
res.render = function(view, options, fn) {
var self = this,
options = options || {},
req = this.req,
app = req.app,
@mrlannigan
mrlannigan / README.md
Last active February 23, 2018 17:08
2018-02-23 [Brown Bag] Node.js Debugging and Profiling

Debugging in Node.js

Preparing the process

First step is to always use at least the latest LTS version of Node (8.x).

Next get acquainted with how to run your process without npm or yarn, for you will need to be able to run it with node process flags. For example, for looking-glass we start our server using an index.js file in the root of the project. So instead of running yarn start, we would run node index.js.

Now by default node doesn't have the "inspector" on in the process. You have to turn it on and there are a couple ways to do that. First, and the most common, is to pass a flag to the command; node --inspect index.js or node --inspect-brk index.js. Next, you can activate it by sending a SIGUSR1 to the running process; kill -s SIGUSR1 <pid>

0x5c033554fba443f04b40197b17d47c5279fce90f
//////////////////////////////////////////////////
// mapping example
var x = {
validate: {
type: 'joi',
key: 'somekey'
}
}
// sidebar: the mapping example
{
"version": "1.0.0"
}
function bind (scope, func) {
return function () {
func.apply(scope, arguments);
};
}
function A() {
this.console.log('hello A, I\'m logging my output via my this because it is bound to the global context');
}