Skip to content

Instantly share code, notes, and snippets.

@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 / btoa-atob.js
Last active November 19, 2017 08:00
btoa & atob
function btoa(str) {
if ((typeof str) !== 'string') {
str = JSON.stringify(str);
}
var buffer;
if (str instanceof Buffer) {
buffer = str;
@leommoore
leommoore / s3_make_a_bucket_public.md
Last active November 9, 2020 18:08
S3 Make a Bucket Public

S3 Make a Bucket Public

By default, files uploaded to Amazon S3 are private, requiring a separate action to make public. To make uploads default to public, add this policy to your S3 bucket.

{
  "Version": "2008-10-17",
  "Statement": [{
    "Sid": "AllowPublicRead",
 "Effect": "Allow",
@leommoore
leommoore / 00.howto_install_phantomjs.md
Last active January 9, 2019 15:38 — forked from julionc/00.howto_install_phantomjs.md
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 2.1.1

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
@leommoore
leommoore / setup-mongodb.sh
Last active October 20, 2017 22:36 — forked from sheikhwaqas/setup-mongodb.sh
Install MongoDB Server on Ubuntu
# Download and Install the Latest Updates for the OS
apt-get update && apt-get upgrade -y
# Set the Server Timezone to CST
echo "America/Chicago" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
# Enable Ubuntu Firewall and allow SSH & MySQL Ports
ufw enable
ufw allow 22

##rsync

If your folder contains subfolders and more importantly symlinks you want to use rsync:

rsync -aruv localfolder/ user@server:destination/

Or in reverse:

rsync -aruv user@server:destination/ localfolder/
@leommoore
leommoore / string-utils.js
Created April 25, 2016 16:13 — forked from jonlabelle/string-utils.js
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str){
return str.toLowerCase();
@leommoore
leommoore / mongodb_3.2.x_reporting.md
Last active November 9, 2020 18:11
MongoDB 3.2.x Reporting

MongoDB 3.2.x Reporting

The find() operator creates a cursor to the data. The client can then parse through the data and do calculations on the data for reports purposes. However, with large data sets this is not practical. It makes far more sense for the server to do the calculations and return the result. This can save a considerable amount of unnecessary network traffic. You can however run the count on the cursor without much overhead.

db.mycollection.find().count()

Mongo has two other methods for reporting on data:

  • Aggregation
  • Map-Reduce
@leommoore
leommoore / mongodb_ssl_with_letsencrypt.md
Last active August 16, 2022 17:35
MongoDB 3.2.x SSL with Letsencrypt

MongoDB 3.2.x SSL with Letsencrypt

Letsencrypt 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. We will look at the what is needed to secure your MongoDB installation. For more details on setting up a MongoDB server see MongoDB 3.2.x.

Set the hostname

We sould to set the hostname to match the name of the certificate we are going to optain.

sudo hostname mongo0.example.com

Then update the hostname file to set the server name permanently.

@leommoore
leommoore / mongodb_3.2.x_security.md
Last active October 19, 2018 00:39
MongoDB 3.2.x Security

#MongoDB 3.2.x Security

##Network Ports The standard ports used by mongo are:

ProcessRoleDefault Port