Things I tend to forget


Brewing Beer vs Distilling Spirits

Compare Brewing Beer, Distilling Spirits, & Making Wine

original at http://www.brewhaus.com/Lets-Compare-Brewing-beer-vs-Distilling-Spirits.aspx

PS. I was actually looking for http://linuxbrew.sh/ 🙂

Similar Posts:

    None Found




WordPress Ajax Skeleton

Similar Posts:




Webmin/VirtualMin with Let’s Encrypt

Virtualmin team said the next version of Virtualmin/Webmin will automate most of the letsencrypt setup. Meanwhile there’s an ongoing conversation about it in the forums

My setup:
./letsencrypt-auto certonly --webroot --webroot-path /usr/share/nginx/html -d my.vmin.server

Then in Webmin > Webmin Configuration > SSL Encryption set:

  • Private key file to /etc/letsencrypt/live/my.vmin.server/privkey.pem
  • Certificate file to /etc/letsencrypt/live/my.vmin.server/fullchain.pem

Add a monthly crontab job to renew the certificate:
/usr/local/letsencrypt/letsencrypt-auto certonly \
--webroot --webroot-path /usr/share/nginx/html -d my.vmin.server \
--renew-by-default \
--agree-tos

Similar Posts:




Php5{en,dis}mod mcrypt

Seriously. I’m doing too much php stuff!

Here are a few things I learned in the last couple of days:

apt-get install php5-mcrypt
dpkg -l php5-mcrypt
ii php5-mcrypt 5.4.6-0ubuntu6 amd64 MCrypt module for php5
php -m | grep -c mcrypt
0
php5enmod mcrypt
php -m | grep mcrypt
mcrypt

And to install xhgui+xhprof, follow this tutorial (README is lacking)

Similar Posts:




Casarecce in Ricotta And dried tomato sauce

image

Similar Posts:

    None Found




Reminder to self: Don’t use == for string comparison in PHP

From SO thread

You should never use == for string comparison. === is OK.

$something = 0;
echo ('password123' == $something) ? 'true' : 'false';

Just run the above code and you’ll see why.

$something = 0;
echo ('password123' === $something) ? 'true' : 'false';

The reason is that when using ‘==’ it will try to convert the string to a number, and match it!

Now where’s the emoji for facepalm?

Similar Posts:




Codeception Testing – Part 2

I’m still setting up for BDD testing. All the basics are already there (see previous post).

I spoke quickly about setting up WPBrowser: WordPress specific set of extensions for Codeception. Here’s what to do (from the Readme):

  1. Require the package in the composer.json, then run “composer update” (details)
  2. Add the WPBrowser or WPWebDriver module in tests/acceptance.suite.yml (details)

The added bonus, if you’re using PhpStorm is that you will also get the related auto-complete package. And there’s plenty of functions that really speed things up.

Next for me was setting up MailCatcher

MailCatcher runs a super simple SMTP server which catches any message sent to it to display in a web interface

You need mailcatcher if you’re testing sending email out from the site. Here’s what I used:
\curl -sSL https://get.rvm.io | bash
source /etc/profile.d/rvm.sh
rvm install 2.2.2
rvm default@mailcatcher --create do gem install mailcatcher
rvm wrapper default@mailcatcher --no-prefix mailcatcher catchmail

You also need to add the following in /etc/php5/apache2/php.ini:

sendmail_path =  /usr/local/rvm/wrappers/default/catchmail -f some@from.address #


(and restart apache after that)

Next you need to install the codeception mailcatcher module using composer

"captbaritone/mailcatcher-codeception-module": "1.*"

And set the configuration inacceptance.suite.yml

You might get by with only that, but I had trouble with mail being routed through special plugins we use at work, so I had to install the ‘mailcatcher’ plugin

After that it was smooth testing …

 

Similar Posts:




Codeception Testing – Part 1

I started working on automating testing ( BDD style ) a few weeks ago, and it took me a while to go over the available tools and options. The obvious starting point was cucumber. Which then led me to Behat, which then took me to Codeception.

When someone tells you it works out of the box, you should always take that with a pinch of salt. Of course, if you follow the quickstart page, it will take you through the different steps that you would take to unwrap the shrink around the box, open it up, take the protective foam bar out, … You get my drift.

Turns out you would need a few more ingredients before you could start testing. Here’s what I needed:

  1. Download and run selenium
  2. Download and install chromedriver
  3. Setup PhpStorm with Codeception

Of course if you’re using the PhpBrowser for testing (no Javascript with that sorry),  you could get started faster. So no nagging please.

And, if you’re like me, going to test WordPress sites themes and plugins, you might find the WPBrowser very useful.

Here’s a list of the steps I took locally on an Ubuntu 15.10 machine (that already had Google Chrome installed)

If you didn’t have Chrome (or installing on a server):

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
dpkg -i google-chrome-stable_current_amd64.deb
apt-get install -f # dirty shortcut to get apt to install dependencies for you!

wget http://goo.gl/rQhaxb -O /opt/selenium-server-standalone.jar
sudo apt-get install xvfb
alias run_selenium="DISPLAY=:1 xvfb-run java -jar /opt/selenium-server-standalone.jar"

wget -N http://chromedriver.storage.googleapis.com/2.20/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
chmod +x chromedriver

sudo mv -f chromedriver /usr/local/share/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver

A couple of parting notes:

  1. WebDriver and PhpBrowser do not work together, one of them must be commented out when you’re testing. Pretty obvious when you think about it!
  2. When  you change browser to ‘chrome’, you should also add ‘http_proxy: direct’ in the acceptance.suite.yml

Similar Posts:




Multiple IP addresses (aliases) for wifi connection on Ubuntu

From: http://askubuntu.com/a/217363/63517

 

I’m assuming you’re running NetworkManager here, you’ve already set up your wireless connection using DHCP and you’re talking about IPv4 here.

While you can’t configure the static addresses in NetworkManager GUI, there’s a hack possible.

  1. Find the connection UUID of the connection configured
    $ nmcli con
    
  2. Add a script in /etc/NetworkManager/dispatcher.d/, containing this starting point:
    #!/bin/bash
    
    WLAN_DEV=wlan0
    MYCON_UUID=31c48409-e77a-46e0-8cdc-f4c04b978901
    
    if [ "$CONNECTION_UUID" == "$MYCON_UUID" ]; then
        # add alias for Network 1: 192.168.0.123/24
        ifconfig $WLAN_DEV:0 192.168.0.123 netmask 255.255.255.0 up
        # add alias for Network 2: 192.168.1.123/24
        ifconfig $WLAN_DEV:1 192.168.1.123 netmask 255.255.255.0 up
    fi
    
  3. Make sure it has the right permissions (chmod +x /path/to/script.sh) and restart NetworkManager:
    $ sudo service network-manager restart
    

Now when you connect to your wireless connection, it should add the two aliases (check with ifconfig.

Similar Posts:




JSON cUrl

json_curl() { curl --header "Accept:application/json" "$@" | python -m json.tool; }

add the line in ~/.bash_aliases

Similar Posts: