Skip to content

Instantly share code, notes, and snippets.

@leommoore
leommoore / node_testing_mocha.markdown
Last active October 4, 2015 08:08
Node - Mocha Testing
@leommoore
leommoore / nginx_basics.md
Last active March 2, 2024 01:13
Nginx Basics

#Nginx Basics for Ubuntu

Please see http://wiki.nginx.org/Main for more information. See http://arstechnica.com/gadgets/2012/11/how-to-set-up-a-safe-and-secure-web-server/ for a tutorial on how to install Nginx.

##Installation To install, you can install the version which is in the standard Ubuntu repositories but it is normally quite old and will not have the latest security patches. The best way is to update the repositories first:

apt-get update
apt-get install python-software-properties

apt-get upgrade

@leommoore
leommoore / node_memcached_basics.md
Last active October 13, 2015 04:58
Node - Memcached Basics

#Node - Memcached Basics

Memcached is an in memory key-value store.

Installing Memcached

apt-get install memcached

To check the version

@leommoore
leommoore / node_installing_node.md
Last active February 20, 2017 09:31
Installing and Compiling Node.js

#Node - Installing and Compiling Node.js

##Simple Install Ubuntu

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

##Compile and Install

@leommoore
leommoore / node_error_handling.md
Last active December 11, 2015 01:38
Node - Error Handling

#Node - Error Handling

##Uncaught Errors

var http = require('http');

http.createServer(function() {
  throw new Error('This will be uncaught');
}).listen(3000);
@leommoore
leommoore / javascript_dictionary.md
Last active October 25, 2018 08:25
JavaScript - Dictionary

#JavaScript - Dictionary

This allows you to store and lookup dictionary name value pairs

###Construction

var Dictionary = function Dictionary(startValues) {  
  this.data = startValues || {};
}
@leommoore
leommoore / javascript_regular_expressions.md
Last active December 12, 2015 02:48
JavaScript - Regular Expressions

#JavaScript - Regular Expressions (Regex)

Regular expressions are a language for describing patterns in string data. It is available in many languages including JavaScript.

Regular expressions are denoted by slashed (/) instead of quotes. ie /Hello/. Also Regular expressions are objects in JavaScript and have a number of methods including test which returns true or false if the pattern is found.

###Search Search return the index of the start of the text (like IndexOf), if it is found. Remember, the first location (ie h) is 0. An result of -1 indicates that the Regex was not found.

@leommoore
leommoore / linux_log_file_monitoring.md
Last active December 17, 2015 11:39
Linux - Log File Monitoring

#Linux - Log File Monitoring

Logwatch is a really useful tool which normally runs as a cron job which mails a summary of the log files to root. It shows a summary of software installed, repeated authentication failures from programs such as sshd and su.

For example running:

logwatch --detail med --range Today --format text --output stdout
@leommoore
leommoore / linux_ssh_basics.md
Last active March 31, 2021 17:03
Linux - SSH (Secure SHell) Basics

#Linux - SSH (Secure SHell) Basics ssh is a secure mechanism to interact with a computer remotely.

##Logging on ssh allows a user to log in remotely to a server with a ssh server running (ie openSSHServer). For example:

ssh pi@192.168.1.2

or, using a domain name like:

@leommoore
leommoore / mongodb_basics.md
Last active May 17, 2018 11:33
MongoDB - Basics

#MongoDB - Basics

##Installation The Debian package management tool (i.e. dpkg and apt) ensure package consistency and authenticity by requiring that distributors sign packages with GPG keys. Issue the following command to import the 10gen public GPG Key:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10

Create a /etc/apt/sources.list.d/10gen.list file using the following command.

echo 'deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen' | sudo tee /etc/apt/sources.list.d/10gen.list