Showing posts with label fast. Show all posts
Showing posts with label fast. Show all posts

Sunday, 10 June 2018

packer: virtualbox

Prep
  • Vagrant
    • vagrant init hashicorp/precise64
    • vagrant up
    • vagrant destroy -f
Generate
  • Packer
    • find ~/.vagrant.d/ -name '*ovf' -ls | grep hashi
    • create ex001.json
      • see below
      • fix "source_path" to ovf file to match your system
    • packer validate ex001.json
    • packer build ex001.json
    • vagrant box add my-box-001 packer_virtualbox-ovf_virtualbox.box --force
Test
  • mkdir test001
  • cd test001
  • vagrant init
    • in generated "Vagrantfile", change 1st line to 2nd line
      •   config.vm.box = "base"
      •   config.vm.box = "my-box-001"
  • vagrant up
  • vagrant ssh
    • cat /var/tmp/welcome.txt
      • should say, "welcome001"
  • vagrant destroy -f
Cleanup
  • vagrant box remove my-box-001 --force
  • vagrant box remove hashicorp/precise64 --force


ex001.json

{
  "builders": [{
      "type": "virtualbox-ovf",
      "source_path": "<path to your home dir>/.vagrant.d//boxes/hashicorp-VAGRANTSLASH-precise64/1.1.0/virtualbox/box.ovf",
      "ssh_username": "vagrant",
      "ssh_password": "vagrant",
      "shutdown_command": "echo 'packer' | sudo -S shutdown -P now"
    }],
    "provisioners": [
        {
            "type": "shell",
            "inline":[ "echo welcome001 > /var/tmp/welcome.txt" ]
        }
    ],
    "post-processors": ["vagrant"]
}


Tuesday, 24 January 2017

Docker: simple example, fast

See github link for instructions on how to run.

docker-compose.yml

version: '2'
services:
    app:
        build:
            context: ./
            dockerfile: app.docker
        ports:
            - "80:80"

app.docker

FROM silintl/ubuntu:16.04

RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
RUN apt-get update
RUN apt-get install -y apache2

WORKDIR /var/www/humankind

RUN echo " \n\
 \n\
    ServerName humankind \n\
    DocumentRoot /var/www/humankind \n\
 \n\
" >> /etc/apache2/sites-available/humankind.conf

RUN a2dissite 000-default.conf && a2ensite humankind.conf

RUN echo "Automation for the People" > /var/www/humankind/index.html

EXPOSE 80
CMD ["apache2ctl", "-D", "FOREGROUND"]

See: https://github.com/pcleddy/mini001

Wednesday, 6 August 2014

Very fast editing over sshfs

Update: this can cause some of your ssh sessions to hang, so be aware of that.

Add this to your ~/.ssh/config

Host myserver.mydomain.com
  ControlMaster auto
  ControlPath /tmp/%r@%h:%p


Then, say you have root access via your ssh pub key

mkdir tmp001
sshfs -o uid=1000 root@myserver.mydomain.com:/var/www tmp001

Now, the files in tmp001 map to your remote /var/www directory. And access to them uses an ssh session that is maintained in your /tmp directory, i.e. all interactions are performed over the same ssh session.

To see the tmp file, if you just opened the sshfs session in the last 10 mins

find /tmp -mmin -10 -ls

Monday, 15 July 2013

Selenium test on CLI in 5 minutes using Java

This took me two weeks to nail down looking at it here and there.
  1. mkdir stests
  2. cd stests
  3. wget http://selenium.googlecode.com/files/selenium-java-2.33.0.zip
  4. unzip selenium-java-2.33.0.zip
  5. mkdir jars
  6. find selenium-2.33.0 -type f -name '*jar' -exec mv -v {} jars \;
  7. rm -rfv selenium-*
  8. mkdir src
  9. vi src/Test.java
    1. use below code
  10. mkdir out
  11. javac -d out -cp 'jars/*' src/MyTest.java
    1. ignore "Notes" output
  12. cd out
  13. rm -rfv org
  14. java -cp '../jars/*:.' MyTest

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

public class MyTest  {
    public static void main(String[] args) {
        WebDriver driver = new FirefoxDriver();
        driver.get("http://www.google.com");
        WebElement element = driver.findElement(By.name("q"));
        element.sendKeys("Cheese!");
        element.submit();
        System.out.println("Page title is: " + driver.getTitle());
        (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver d) {
                return d.getTitle().toLowerCase().startsWith("cheese!");
            }
        });
        System.out.println("Page title is: " + driver.getTitle());
        driver.quit();
    }
}

Monday, 13 May 2013

Put stuff on your Nexus 4


  1. apt-get install gmtp
  2. Make sure your "Storage" is in MTP mode
P.S. Or, if you have access to a Mac: "Android File Transfer"

Sunday, 28 April 2013

Ubuntu: convert desktop to server fast

Below as root:
  1. apt-get remove ubuntu-desktop
  2. apt-get install linux-server linux-image-server
  3. apt-get purge lightdm
  4. /etc/default/grub, change matching lines to below
    1. #GRUB_HIDDEN_TIMEOUT [comment it out]
    2. GRUB_CMDLINE_LINUX_DEFAULT=""
    3. GRUB_TERMINAL=console
  5. update-grub
  6. reboot

Thursday, 25 April 2013

Quick CLI screenshots on Linux or Openbox / Fluxbox


  1. sudo apt-get -y install imagemagick eog
  2. import myscreenshot.jpg
    1. select portion of screen with the crosshairs
  3. eog myscreenshot.jpg

Wednesday, 24 April 2013

Friday, 12 April 2013

Cassandra in 30 seconds


  1. writes 
    1. writes entries directly to disk without checking if they already exist
    2. does fancy indexing of entries
    3. returns a write "OK" to the writing client after a quorum of nodes have confirmed
  2. reads
    1. tries to return the newest entry when client does a read
    2. has methods to eventually get the newest entry to return even if old ones still around
  3. replication
    1. stores entries to multiple nodes if replication is turned on
  4. deletes
    1. doesn't offically delete, just marks dead entries with a "tombstone"
    2. compaction is what gets rid of old versions of entries and dead entries
  5. balancing
    1. automatically fills in data holes if a node disappears
    2. automatically spreads data if new nodes are added
  6. resurrection
    1. 3-nodes: X, Y, Z, all replicate all data
    2. server X goes down
    3. delete goes to Y and Z for key A
    4. Y and Z are "compacted"
      1. i.e., redundant keys & tombstones cleaned up / removed
      2. key A is completely gone as far as  Y and Z know
    5. X comes up and has value for key A
    6. A is back! resurrected from the dead! life sucks.
    7. NOTE: if Y and Z didn't have tombstones removed, they would have had a date that was more recent than X's key A entry, so they would have invalidated X's key A. But, they are gone after a compaction or cleanup.

Interview questions: 2020-12

Terraform provider vs provisioner Load balancing Network Load Balancer vs Application Load Balancer  Networking Layer 1 vs Layer 4 haproxy u...