Skip to content

Instantly share code, notes, and snippets.

View andris9's full-sized avatar
🇪🇪

Andris Reinman andris9

🇪🇪
View GitHub Profile
@andris9
andris9 / README.md
Last active December 29, 2022 02:38
Extremely simple HTTP proxy for changing Host: header Useful when proxying requests to virtual hosts that require Host: header to be set.

Setup reverse tunnel

Run the following in your client machine

ssh -R EXPOSED_PORT:localhost:SERVICE_PORT USER@HOST

Where

  • EXPOSED_PORT is the port exposed to the internet in the proxy server
  • SERVICE_PORT is the port your application is listening in your machine
@andris9
andris9 / uuencoded.js
Created June 4, 2014 07:17
Parse uuencoded attachments from a text message
// Install uue decoder:
// npm install uue
var message =
'This is a message with uuencoded attachment\n' +
'\n' +
'begin 644 cat.txt\n' +
'#0V%T\n' +
'`\n' +
'end\n';
{
"plugins": ["ID", "X-GM-EXT-1", "XOAUTH2", "STARTTLS", "SASL-IR", "AUTH-PLAIN", "NAMESPACE", "IDLE", "ENABLE", "CONDSTORE", "XTOYBIRD", "LITERALPLUS", "UNSELECT", "SPECIAL-USE", "CREATE-SPECIAL-USE"],
"debug": true,
"secureConnection": true,
"port": 993,
"smtpPort": 465,
"users": {
"testuser": {
"password": "testpass",
"xoauth2": {
@andris9
andris9 / id_rsa.pub
Created June 23, 2015 07:39
My public key for SSH
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDX+dz7lssGpOWQBpq0+F9E0mrBnZx4NKdo/7vxF2ppybutKr6a5mN0oeu/EkUGdjJol7tGxmHqvmZUrXkwH1ZUfAQ6HTY3kl6YPiFhCWmypN/jfqPQke9vz1RVzaqjf92zoJITlOdaEmQqoAF0Lj+WZNsu83wVUSvlCdvLLgFKqVyQlCWRJ+cm/iCAGSo+47Qj2zqiN0WGURaFN6Cf8p+tzRUyvsZDaFCjNtmXZPay8IqzplysWZNiqRkkDDJeY87uyQGenMK785khcG+26F/dDyaK/q3mMSJuQaVHGs90pNCclLuAcTOtz/VO2hgNVBPFJROWH5bp2dlLd1n0kTqd andris@kreata.ee
'use strict';
// npm install nodemailer nodemailer-smtp-pool
var nodemailer = require('nodemailer');
var smtpPool = require('nodemailer-smtp-pool');
// Create a SMTP transporter object
var transport = nodemailer.createTransport(smtpPool({
host: 'smtp.gmail.com',
port: 465,
secure: true,
@andris9
andris9 / mandrill.js
Last active August 10, 2022 20:38
Nodemailer using Mandrill
'use strict';
// Nodemailer: v2.0.0
// Ubuntu: 14.04
// node: v5.5.0
// npm: 3.3.12
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
service: 'Mandrill',
@andris9
andris9 / test.js
Last active May 25, 2016 09:36
nodemailer test
'use strict';
var nodemailer = require('nodemailer');
var smtp = require('nodemailer-smtp-transport');
var options = {
service: 'gmail',
auth: {
user: 'username',
pass: 'password'
@andris9
andris9 / test.js
Created June 10, 2016 07:11
sort vs binsearch
/* eslint-env browser */
/* eslint no-bitwise: 0, no-console: 0*/
'use strict';
function binSearch(haystack, needle, comparator, low, high) {
var mid, cmp;
if (low === undefined) {
low = 0;
@andris9
andris9 / USAGE.md
Created September 1, 2016 08:43
Replace domain name in Wordpress database dump

wp-domain-change

Simple script to replace domain name in a Wordpress MySQL dump file. In addition to replacing domain names in standard string values, the script is able to correctly replace strings in serialized PHP values. This means that it should be safe to operate on data from wp_options table where plugins store data as serialized PHP

Usage

Run the script from command line. First argument is the domain name to replace and the second is the replacement. SQL dump is read from stdin and written to stdout

node wp-domain-change.js "http://source.domain" "http://dest.domain" < input.sql > output.sql

@andris9
andris9 / install.md
Last active October 18, 2016 12:55
Mailtrain install Zone serveris

Mailtrain install Zone serveris

1. Tekita vajalikud failid

Logi SSH kaudu oma virtuaalhosti sisse ja tekita oma juurkausta (st. see kuhu peale ssh logimist satud, n. /data01/virt12345) allpool näidatud failid mailtrain.json ja mailtrain.toml (viimast faili tuleks enne salvestamist veidi muuta, nimelt tuleks üle vaadata MySQL ja Redis parameetrid vastavalt oma konto seadistusele).

Andmebaasitabeleid seadistada vms. ei ole vaja, seda teeb Mailtrain esimesel käivitusel automaatselt.

2. Lae alla Mailtraini kood