Skip to content

Instantly share code, notes, and snippets.

@trompx
trompx / elasticsearch-handlers-main.yml
Created November 3, 2016 11:07 — forked from labrown/elasticsearch-handlers-main.yml
Ansible rolling restart of Elasticsearch Cluster
---
###
# Elasticsearch Rolling restart using Ansible
###
##
## Why is this needed?
##
#
# Even if you use a serial setting to limit the number of nodes processed at one
@trompx
trompx / smashingmagazine.js
Created September 28, 2016 10:26 — forked from luruke/smashingmagazine.js
Source code of the demo "Improving User Flow Through Page Transitions" on Smashing Magazine.
/*
https://www.smashingmagazine.com/2016/07/improving-user-flow-through-page-transitions/
You can copy paste this code in your console on smashingmagazine.com
in order to have cross-fade transition when change page.
*/
var cache = {};
function loadPage(url) {
if (cache[url]) {
<?php
/*
Author: Hans2103
credit: Jim Westergren, Jeedo Aquino & Flynsarmy
File: index-with-redis.php
Updated: 2013-05-27
This is a redis caching system for Wordpress based on Redis connection using PHPRedis.
https://github.com/nicolasff/phpredis

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost

@trompx
trompx / encrypt_openssl.txt
Created November 1, 2015 21:38 — forked from crazybyte/encrypt_openssl.txt
File encryption using OpenSSL
For symmetic encryption, you can use the following:
To encrypt:
openssl aes-256-cbc -salt -a -e -in plaintext.txt -out encrypted.txt
To decrypt:
openssl aes-256-cbc -salt -a -d -in encrypted.txt -out plaintext.txt
For Asymmetric encryption you must first generate your private key and extract the public key.
@trompx
trompx / Vagrant-LEMP-ubuntu.sh
Created October 23, 2015 01:05 — forked from mosufy/Vagrant-LEMP-ubuntu.sh
Vagrant LEMP Stack Installation Bash Script for Ubuntu 14.0.4
#!/usr/bin/env bash
# Variables
APPNAME=appname
DBHOST=localhost
DBNAME=db_app
DBUSER=user1
DBPASSWD=password1
# Update the box
@trompx
trompx / haproxy-db.conf
Last active September 21, 2015 12:23 — forked from aw/haproxy-db.conf
HAProxy configuration for MySQL failover and redundancy
# HAProxy configuration - haproxy-db.cfg
##
## FRONTEND ##
##
# Load-balanced IPs for DB writes and reads
#
frontend db_write
bind 172.16.0.50:3306
@trompx
trompx / cron_helper.sh
Last active August 29, 2015 14:27 — forked from liquidgecka/cron_helper.sh
Cron helper
#!/bin/bash
usage() {
cat << EOF
Usage: $0 [OPTION]... COMMAND
Execute the given command in a way that works safely with cron. This should
typically be used inside of a cron job definition like so:
* * * * * $(which "$0") [OPTION]... COMMAND
Arguments:
vagrant@ubuntu-12:/docker-pub/redis$ cat base/2.8.1/Dockerfile
FROM ubuntu:12.10
MAINTAINER James McKernan james@hvflabs.com
RUN apt-get update
RUN apt-get install -y build-essential
ADD redis-2.8.1.tar.gz redis-2.8.1.tar.gz
RUN tar xvfz redis-2.8.1.tar.gz
RUN cd redis-2.8.1 && make
RUN cd redis-2.8.1 && make install
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db