Skip to content

Instantly share code, notes, and snippets.

@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 / javascript_ANSI_escape_codes.md
Last active April 30, 2024 01:48
JavaScript - ANSI Escape Codes

JavaScript - ANSI Escape Codes

ANSI Escape Codes are special characters which can be used to control formatting, colors or other output preferences in a text terminal. Escape Codes are non-printing code and will not appear in the output directly.

  • \033 begins the escape sequence
  • [ indicates the color
  • 33 is the foreground color for yellow
  • m indicates the end of the setting

Note: \033[39m is used set the color back to the terminal defult

@leommoore
leommoore / systemd_services.md
Last active April 25, 2024 02:46
Systemd Services 101

Check that your system supports systemd

pidof systemd
2733

If this return a number then your system supports systemd. Most Linux distributions in 2017 support systemd.

Check out the proceses currently running.

Since systemd starts the process then all processes will be children of systemd

@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_create_a_redirect_server.md
Created April 1, 2014 10:30
Create a redirect server in Node.js

#Create a redirect server in Node.js

'use strict'

var http = require('http');

var mappings = {
 g: 'http://www.google.com'
@leommoore
leommoore / windows_node_gyp_compile_problems.md
Last active January 17, 2024 12:26
Windows node-gyp Compile Problems

#Windows node_gyp Compile Problems

When you are compiling node-gyp components during the npm install process you may hit problems when it tries to figure out the version of Microsoft C++ that you have available.

##Typical Problems

fatal error C1083: Cannot open include file: 'vcruntime.h': No such file or directory
@leommoore
leommoore / ubuntu_adding_ca_certs.md
Created June 21, 2014 17:19
Ubuntu - Adding CA Certs

#Ubuntu - Adding CA Certs

To add new Certificate Authority (CA) certs:

  1. Create a directory (ie extra) in the ca-certs to hold the new certs

    sudo mkdir /usr/share/ca-certificates/extra

  2. Copy or move the certs into the new directory

#SOA Manifesto

In 2002, Jeff Bezos (CEO of Amazon), issued a mandate requiring all teams to expose their data and functionality through services interfaces. Jeff Bezos understood that in order for his company to be successful, he had to switch focus from creating a "perfect product" to creating a perfect platform for that product.

He mandated that:

  • All teams will henceforth expose their data and functionality through service interfaces
  • Teams must communicate with each other through these interfaces
  • There will be no other form of interprocess communication allowed: no direct linking, no direct reads of another team's data store, no shared-memory model, no back-doors whatsoever. The only communication is via service interface calls over the network.
  • It doesn't matter what [API protocol] technology you use
@leommoore
leommoore / nano_js_syntax_highlighting.md
Last active October 5, 2023 21:21
nano javascript syntax highlighting

#nano javascript syntax highlighting

The existing syntax highlighting is located in /usr/share/nano/

To add a new language

sudo nano /usr/share/nano/javascript.nanorc

Put the following in the contents: