Skip to content

Instantly share code, notes, and snippets.

@leommoore
leommoore / linux_partitions.md
Last active February 1, 2016 19:24
Linux Partitions

#Linux Partitions The best time to partition is when you are doing a fresh install.

  1. In Ubuntu, when you are prompted to erase the disk, select 'Something Else' and click 'Continue'. You will see a single device /dev/sda.
  2. Click the 'New Partition Table..' button. Read the warning and click 'Continue'
  3. Select the free space and click on the '+' button next to Change to create a partition.
  4. Main System Partition - Can be as little as 15-20Gb or larger if necessary. Choose the Gb figure and multiply by 1024 and enter the figure in the size box. Leave 'Primary','Beginning of this space' and 'Ext4 journaling file system'. Select '/' under the mount point and click 'OK'
  5. Select the remaining space and click '+' again. Click on the 'Use as' dropdown menu and select 'swap area'. Set the partition type as Logical, but set its location as 'End of this space'. The size should be approximately the same as the memory or at least 1Gb. Choose a figure and multiply by 1024 to get the Mb figure
@leommoore
leommoore / letsencrypt_ubuntu_nginx.md
Last active August 8, 2018 10:37
Letsencrypt Ubuntu 14.04 Nginx

#Letsencrypt Ubuntu 14.04 Nginx Letsencrypt (https://letsencrypt.org) is an initative which aims to increase the use of encryption for websites. It basically allows people to apply for free certificates provided that they prove the they control the requested domain.

Note: As of 8th March 2016 letsencrypt is still in public beta.

##Installation To install the client, clone the repostiory from github.

git clone https://github.com/letsencrypt/letsencrypt.git
@leommoore
leommoore / file_magic_numbers.md
Last active May 2, 2024 14:47
File Magic Numbers

File Magic Numbers

Magic numbers are the first bits of a file which uniquely identify the type of file. This makes programming easier because complicated file structures need not be searched in order to identify the file type.

For example, a jpeg file starts with ffd8 ffe0 0010 4a46 4946 0001 0101 0047 ......JFIF.....G ffd8 shows that it's a JPEG file, and ffe0 identify a JFIF type structure. There is an ascii encoding of "JFIF" which comes after a length code, but that is not necessary in order to identify the file. The first 4 bytes do that uniquely.

This gives an ongoing list of file-type magic numbers.

Image Files

@leommoore
leommoore / S3Cmd.md
Last active May 25, 2022 11:14
S3Cmd

S3Cmd - S3 Command Line Tools

S3cmd is a free command line tool and client for uploading, retrieving and managing data in Amazon S3 and other cloud storage service providers that use the S3 protocol, such as Google Cloud Storage or DreamHost DreamObjects. It is best suited for power users who are familiar with command line programs. It is also ideal for batch scripts and automated backup to S3, triggered from cron, etc.

S3cmd is written in Python. It's an open source project available under GNU Public License v2 (GPLv2) and is free for both commercial and private use. You will only have to pay Amazon for using their storage.

It is available on http://s3tools.org/s3cmd

Installing S3Cmd

@leommoore
leommoore / ssl_basics.md
Last active May 9, 2018 16:39
SSL Basics

#SSL Basics

Secure Socket Layer (SSL) is a mechanism to allow information to be securely communicated. Specifically, it is a cryptographic protocol that enables two parties such as a web server and a browser to exchange information securely by encrypting it before sending and decrypting it upon receipt. It is based on the X.509 standards.

##Symmetric and Asymmetric Encryption Encrypting and decrypting requires a secret like a password, which is known as a key. There are two types of key, symmetric and asymmetric. If a symmetric key is used it means that the same key is used to encrypt and decrypt the message. Asymmetric keys consist of a private and public key. The message sender encrypts the message using their private (secret) key and the message receiver can decrypt the message using the senders public key.

Asymmetric keys require more processing resources than symmetric keys. The problem is that to communicate using symmetric keys both parties have to have the symmetric keys first and the question is

@leommoore
leommoore / JavascriptCalculatingStandardDeviations.md
Last active May 25, 2022 11:19
Javascript - Calculating Standard Deviations

Javascript - Calculating Standard Deviations

This is based on a excellent post by Derick Bailey.

function standardDeviation(values){
  var avg = average(values);
  
 var squareDiffs = values.map(function(value){
@leommoore
leommoore / mongodb_indexes.md
Last active May 31, 2018 06:59
MongoDB Indexes

#MongoDB Indexes There are 5 different index types supported in MongoDB.

  1. Regular (B-Tree) - supports indexes on a single or multiple fields
  2. Geo - supports indexing on a geographical location (useful for finding locations nearby)
  3. Text - Allows for search engine like full text searching
  4. Hashed - This is used primarily used for sharding as it evenly distributes the hashes rather than clustering them.
  5. Time to Life - This supports expiring based on a document date field

##Create Index

@leommoore
leommoore / mongodb_javascript.md
Last active October 28, 2016 02:03
MongoDB - JavaScript

#MongoDB - JavaScript Since a query may return a large number of records which is too large for the client, the find returns a cursor instead of the data. This cursor can be assigned to a variable.

var vendorCursor = db.vendors.find();

You can see the size of the cursor using:

vendorCursor.size();

You can check to see if there is more data after the current cursor point in the data set using:

@leommoore
leommoore / ubuntu_installing_java.md
Last active August 10, 2016 21:07
Ubuntu - Installing Java

#Ubuntu - Installing Java

##Java 8 sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer

##To install the JDK

sudo apt-get install python-software-properties

@rtgibbons
rtgibbons / logger.js
Created November 7, 2013 13:51
Logger Library with winston
var app = require(process.cwd() + '/app');
var winston = require('winston');
var _ = require('lodash');
// Set up logger
var customColors = {
trace: 'white',
debug: 'green',
info: 'green',
warn: 'yellow',