Skip to content

Instantly share code, notes, and snippets.

@alvarow
alvarow / lvm2-cheat.sh
Last active August 19, 2018 15:42
Linux LVM Cheat sheet
# creates an LVM under a single device
dd if=/dev/zero of=/dev/sdb bs=512 count=64
pvcreate /dev/sdb
pvs
vgcreate timeline /dev/sdb
lvcreate -n app -l 100%FREE timeline
mkfs.xfs -L APP /dev/timeline/app
echo '/dev/timeline/app /app xfs noatime 1 2' >> /etc/fstab
mkdir -p /app && mount /app
@alvarow
alvarow / openssl-cheat.sh
Last active June 28, 2024 18:22
OpenSSL and Keytool cheat sheet
# Generate a new key
openssl genrsa -out server.key 2048
# Generate a new CSR
openssl req -sha256 -new -key server.key -out server.csr
# Check certificate against CA
openssl verify -verbose -CApath ./CA/ -CAfile ./CA/cacert.pem cert.pem
# Self Signed
@alvarow
alvarow / post_preservation.php
Created March 3, 2016 15:12
HTTP POST Preservation in PHP
<?php
echo '<html><body>';
?>
<script>
function submitForm() {
oCombo = document.getElementById('idURLCombo');
oForm = document.getElementById('idMainForm');
oForm.action = oCombo.value;
oForm.submit();
}
@alvarow
alvarow / embedded_perl_script.sh
Created March 3, 2016 15:17
Embedded perl script in shell
!#/bin/bash
cat > embedded_perl_script<<'EOF'
#!/usr/bin/perl -w
$input = $ARGV[0];
my $argc;
$argc = @ARGV;
print $input."\n"
EOF
@alvarow
alvarow / print-headers.jsp
Last active April 10, 2020 20:13
Print HTTP request headers in JSP
<%@ page import="java.util.*" %>
<html>
<head>
<title>Http Request Headers Example in JSP</title>
</head>
<body>
<h2>HTTP Request Headers Received</h2>
<table>
@alvarow
alvarow / tomcat-init.sh
Created March 3, 2016 15:25
Tomcat init script - Tested on SuSE
#!/bin/sh
### BEGIN INIT INFO
# Provides: tomcat
# Required-Start: $network $time $syslog
# Should-Start: $time
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Tomcat Daemon under /opt/tomcat
# Description: Starts Tomcat under /opt
@alvarow
alvarow / apache-httpd-init.sh
Created March 3, 2016 15:28
Apache init script
#! /bin/sh
#
### BEGIN INIT INFO
# Provides: Apache
# Required-Start: $network
# Required-Stop:
# Default-Start: 3 5
# Default-Stop:
# Description: Apache Web Server
### END INIT INFO
@alvarow
alvarow / node-https-server.js
Created April 8, 2016 20:48
node.js https server example
// curl -k https://localhost:8000/
const https = require('https');
const fs = require('fs');
const options = {
passphrase: '1234',
dhparam: fs.readFileSync('dhparam.pem'),
key: fs.readFileSync('cert.key'),
cert: fs.readFileSync('cert.pem'),
@alvarow
alvarow / mongodb-lvm2.txt
Created April 13, 2016 16:13
EC2 MongoDB Backup LVM
apt-get install lvm2
pvcreate /dev/xvdf
pvs
vgcreate backups /dev/xvdf
lvcreate -n mongodb -l 100%FREE backups
mkfs.ext3 -L MONGOBACKUP /dev/backups/mongodb
echo '/dev/backups/mongodb /var/backups/mongodb ext3 defaults 1 2' >> /etc/fstab
mkdir -p /var/backups/mongodb
chmod 750 /var/backups/mongodb
mount /var/backups/mongodb
@alvarow
alvarow / exifttool-cheat.sh
Last active April 28, 2016 18:24
exiftool scratch pad
# Adjust GPS tag on files in a folder
exiftool -GPSLongitudeRef=W -GPSLongitude="73.87538" -GPSLatitudeRef=N -GPSLatitude=40.850581 -ext cr2 jpg jpeg .
# Move files into Year/Month folders in a given folder
exiftool "-Directory<DateTimeOriginal" -d "%Y/%m" DIR
# Rename files in a folder using Year Month Day Hour Minute Second format
exiftool '-FileName<CreateDate' -d %Y%m%d_%H%M%S%%-c.%%e DIR
exiftool -AllDates+=1 *.JPG
# Adjust file modification date
exiftool "-DateTimeOriginal>FileModifyDate" *.JPG
# Copy tags from another file