CSS Nesting and Why Its a Good Thing

Please read this first: https://signalvnoise.com/posts/3003-css-taking-control-of-the-cascade

So, in CSS we can establish a hierarchy so that a class only applies if it’s within a parent class. This hierarchy is a good and very much needed thing. Because this way you can define your class names for specific areas of the site with freedom of mind – it will never interfere with or be overwritten by another class that has (accidentally) the same name. Think of class names such as .title. And no, .newsletter-title and .homepage-newsletter-title is not a good idea (CSS supports native hierarchy, so why would you want to fake it?).

Example of SASS Good Practise:

.newsletter
   margin: 20px

   .title-box
         .title
             margin-top: 20px

        .subtitle
            margin-top: 10px

     .email-input
         padding: 50px

Example of SASS Bad Practise:

.title
    margin-top: 20px

.subtitle
    margin-top: 10px

.email-input
    padding: 5px

.newsletter
    margin: 20px

You agree? Are you ready to overshoot the target? Read this: http://thesassway.com/beginner/the-inception-rule

Fachmessen

http://www.igeho.ch/ – November 2017 – Basel
http://www.baselworld.com/ – März 2017 – Basel
http://www.svit-immo-messe.ch/ – März 2017 – Zürich

Trigger jenkins deployment from github push with ansible

We are looking at a simple and robust way to automate deployment. The following show some of the non-intuitive things necessary to set this up.

Jenkins

  • I recommend using the github oauth plugin for authentication and of course the github plugin to easily clone github repos.
  • use https://wiki.jenkins-ci.org/display/JENKINS/Build+Token+Root+Plugin – because the default endpoint to trigger builds cannot be accessed by anonymous users
  • Do not allow job names with spaces: In the jenkins global settings look for Restrict project naming and enter \S*
  • Set up a jenkins job for the repository that contains your ansible deploy script
  • Set up jenkins like this with the following Dockerfile
FROM jenkins
# if we want to install via apt
USER root
# stuff required by jenkins jobs, inlcuding ansible
RUN apt-get update && apt-get install -y php5-cli php5-curl python-setuptools python-dev build-essential libssl-dev libffi-dev

RUN easy_install pip
RUN pip install virtualenv

USER jenkins

Ansible

This script bootstraps ansible

#!/bin/bash

# exit the bash script if one of the command returns an error code
set -e

# Setup a proper path, I call my virtualenv dir "venv" and
# I've got the virtualenv command installed in /usr/local/bin

echo "setting path variable"
PATH=$WORKSPACE/venv/bin:/usr/local/bin:$PATH

echo "create virtualenv"
if [ ! -d "venv" ]; then
    virtualenv venv
fi

echo "activate virtualenv"
source venv/bin/activate

echo "installing ansible"
pip install ansible boto httplib2

echo "tossing in some secrets"
# use the secret file function in jenkins to fill in these variables
mkdir credentials
echo "move $all_yml, $deploy_key_pem and $server_stage_pem to $(pwd)/credentials"
mv "$all_yml" credentials/
mv "$deploy_key_pem" credentials/
mv "$server_stage_pem" credentials/

chmod 600 -R credentials/*

# if ansible roles are pulled in from other git repos:
git submodule update --recursive

echo "deploying"
./deploy stage 3-deploy-site.yml

Github

  • Set up a webhook. Example: http://jenkins.what.digital/buildByToken/build?job=Job-Name&token=2093....234

Email Gateway Provider credentials / connection test

Here I am using sparkpostmail.com

openssl s_client -starttls smtp -crlf -connect smtp.sparkpostmail.com:587

Type

auth login

Enter the baes64 encoded username that you get as follows:

echo -n "SMTP_Injection" | openssl base64

Do the same for the password.

Full conversation:

250 PIPELINING
auth login
334 VXNlcm5hbWU6
U01UUF9JbmplY3Rpb24=
334 UGFzc3dvcmQ6
ZTU1......MQ==
235 2.0.0 Authed. Go on.

auth plain:

echo -ne "\0User Name\123123123" | base64

Hint: Use swaks for testing and full smtp logging output:

brew install swaks
swaks -server smtp.sparkpostmail.com:587 -tls --auth-user SMTP_Injection --auth-password 123123123 --to mario@what.digital --from mario@what.digital --auth PLAIN

Simple Squid on Docker Setup

Prerequisites

  • Linux Debian Jessie
  • root access

Install Docker

Add the following to /etc/apt/sources.list.d/docker.list

deb https://apt.dockerproject.org/repo debian-jessie main

Install Docker and some required dependencies:

apt-get update
apt-get install apt-transport-https ca-certificates apache2-utils docker-engine
service docker start

Squid

add this to /srv/docker/squid/squid.conf (example squid.conf)

auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid3/squid_passwd
acl ncsa_users proxy_auth REQUIRED
http_access allow ncsa_users

Create the password file

touch /srv/docker/squid/squid_passwd
chown proxy /srv/docker/squid/squid_passwd
htpasswd /srv/docker/squid/squid_passwd user1

Get the docker image:

docker pull sameersbn/squid:latest

Run the docker container

docker run --name squid -d --restart=always   --publish 3128:3128   \
--volume /srv/docker/squid/squid.conf:/etc/squid3/squid.conf   \
--volume /srv/docker/squid/cache:/var/spool/squid3   \
--volume /srv/docker/squid/squid_passwd:/etc/squid/squid_passwd   \
sameersbn/squid:latest

Sources