Showing posts with label simple. Show all posts
Showing posts with label simple. 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

Thursday, 29 December 2016

simple angularjs 1.x webapp

Here's a very simple app using AngularJS 1.x.

Hints:

  • Ignore how the first couple of lines in app.js work, and just use as is.
  • Anything in index.html that starts with "ng-" is a "angular directive", fancy term for a placeholder. Angular repeatly scans the DOM for these, gulps them up and runs them. Sometimes it is just a div, sometimes the whole body. You decide how much of the DOM a directive needs to control. Try to keep it as small as possible.

Code: https://github.com/pcleddy/wordcounter
Live app: http://bit.ly/2iiEuoY (I hope)

Maybe try to play with app.js to see if you can add some functionality using m_words.

Thursday, 25 June 2015

create simple mysql table for testing

CREATE TABLE suppliers (
    SupplierID SMALLINT UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT,
    SupplierName VARCHAR(40) NOT NULL,
    Phone VARCHAR(14) NOT NULL,
    Email VARCHAR(60) NULL,
    PRIMARY KEY (SupplierID)
 );

INSERT INTO suppliers (SupplierName, Phone, Email) VALUES ('ABCSupplier','1122334455','abc@dicforum.com');

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

Friday, 15 March 2013

Simple Ruby email out localhost:25, no OpenSSL::SSL::SSLError, no tlsconnect error

Notes:
  1. This skips the common OpenSSL::SSL::SSLError / tlscommon errors somehow, see below for error output.
  2. DON'T use pony's "smtp" hash option, it has the same problem. Notice it is missing here!
Steps:
  1. gem install pony
  2. take below code 
    1. put in ~/bin/mail_test.rb
    2. tweak for your environment
    3. chmod +x ~/bin/mail_test.rb 

https://github.com/pcharlesleddy/misc/blob/master/mail_test.rb

#!/usr/bin/ruby

require 'rubygems'
require 'pony'

mystring = "a\nb\nc"

Pony.mail(:to => 'abc@efg.org', :from => 'me@example.com', :subject => 'Test mail script', :body => 'Hello there.', :attachments => {"mail_test.txt" => File.read("/home/me/bin/mail_test.rb"), "mystring.txt" => mystring})


Common, irritating tlscommon error:

/usr/lib/ruby/1.8/openssl/ssl-internal.rb:123:in `post_connection_check': hostname was not match with the server certificate (OpenSSL::SSL::SSLError)
from /usr/lib/rvm/gems/ruby-1.9.3-p194/gems/mail-2.5.3/lib/mail/core_extensions/smtp.rb:17:in `tlsconnect'
from /usr/lib/ruby/1.8/net/smtp.rb:562:in `do_start'
#!/usr/bin/ruby
from /usr/lib/ruby/1.8/net/smtp.rb:525:in `start'
from /usr/lib/rvm/gems/ruby-1.9.3-p194/gems/mail-2.5.3/lib/mail/network/delivery_methods/smtp.rb:136:in `deliver!'
from /usr/lib/rvm/gems/ruby-1.9.3-p194/gems/mail-2.5.3/lib/mail/message.rb:245:in `deliver!'
from /usr/lib/rvm/gems/ruby-1.9.3-p194/gems/pony-1.4/lib/pony.rb:166:in `deliver'
from /usr/lib/rvm/gems/ruby-1.9.3-p194/gems/pony-1.4/lib/pony.rb:138:in `mail'

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...