Categories
Docker

Docker

Useful commands
grabs ip address

sudo docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' some-mariadb

Categories
Ruby

Develop using ruby in a docker – ver 1.0

Just messing around with docker and the ruby container.  Didnt call gems yet but following instructions in https://hub.docker.com/_/ruby, got a quick ruby environment running.

working directory: /src/docker-ruby


#ruby.sh
#chmod 755 ruby.sh

[ruby.sh]
#!/bin/bash
  
sudo docker run -it --rm --name some-ruby -v "$PWD":/src/docker-ruby -w /src/docker-ruby ruby:2.6.0 ruby ./start.rb
chmod 755 ruby.sh 
#run as ./ruby.sh

[start.rb]
class MegaGreeter
  attr_accessor :names
def initialize(names="World")
@names = names
end

def say_hi
if @names.nil?
puts "..."
elsif @names.respond_to?("each")
@names.each do |name|
puts "Hello #{name}!"
end
else
puts "Hello #{@names}!"
end
end

def say_bye
if @names.nil?
puts "..."
elsif @names.respond_to?("join")
puts "Goodbye #{@names.join(", ")}. Come back soon!"
else
puts "Goodbye #{@names}. Come back soon!"
end
end
end

if __FILE__ == $0
mg = MegaGreeter.new
mg.say_hi
mg.say_bye

mg.names = "Zeke"
mg.say_hi
mg.say_bye

mg.names = ["Albert", "Brenda", "Charles", "Dave", "Engelbert"]
mg.say_hi
mg.say_bye
mg.names = nil
mg.say_hi
mg.say_bye
end

greeter = MegaGreeter.new("rob")
greeter.say_hi
puts "Great day!"

greeter.say_bye
Categories
Docker

Docker

 

My most commonly used docker images:
postgres

docker run --name some-postgres -v /data/raw/:/data/raw/ -v /data/postgres:/var/lib/postgresql/data -d postgres

portainer: nice docker web gui.  It includes templates you may dnload without going to command line.

sudo docker volume create portainer_data
sudo docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer

redis – Started from portainer
rabbitmq – started from portainer

Categories
Wordpress

WordPress

Updating files on a remote server with ftp is scary.  I like ssh.  Install a very cool wordpress plugin called “SSH Sftp Updater Support”.

    The easiest way I found is to:

  • download to local system and remote ssh it to the server.
  • unzip and install in wordpress/wp-content/plugins

may have to restart apache, I dont know. Now you have ssh as an option now.

SSH Sftp Updater Support

Categories
Web

Apache2

Apache user permission settings – very useful!


# Set ownership to web user
sudo chown -R ${USER}:www-data /var/www

# Change all files read write to user and group
find /var/www -type f -exec chmod 0660 {} \;

# Change all directories to read write execute attributes
# AND setting the sticky bit to 2 results in this happening
# only to directories
sudo find /var/www -type d -exec chmod 2770 {} \;

This link explains well and I like it!
Permissions for web

Categories
Mariadb

Mariadb

Reminder: backup your database!

mysqldump -u username -p database_name > database_name.20190118.sql
sudo docker run --name some-mariadb -v /data/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mariadb:latest
Categories
Development

Development

My coding rules:

  • Versioning in git: [major].[minor].[patch]-[build/beta/release]
  • Javascript coding:
    • structure
      • use strict
      • es6 – watch the shorthand functions
      • I like airbnb except for string handling.  I use both single/double quote
    • modules to use
      • webpack
      • babel
      • eslint
      • sass
    • directory structure
      • main
      • modules: for javascript modules I write
      • public
        • js: js scripts used in html
        • views:  html/ejs/etc goes here
        • css
      • data: data used with this project-spreadsheets, files, database schema
Categories
Git

GIT

Important git commands used more often
Committing files to wrong branch – in this case: master

git reset HEAD~
git commit -c ORIG_HEAD

Adding version number(tag) to commit

git tag -a "v1.0.0-beta"

List version numbers used

local: git tag --list
remote: git ls-remote --tags 

Push tags to remote

git push --tags

status including neat branch graph

git status
git log --graph

push branch to local and remote

git checkout -b new_branch_name
git commit -m "new branch"
git push -u origin new_branch_name
Categories
Git

Git

git – switch branches


git -b mybranch (-b creates a new branch)
Categories
React

React Babel

When creating a quick react component in an html page, you will need to use babel to translate the jsx into something readable.

from :  https://reactjs.org/docs/cdn-links.html

and babel:

<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></scri
<!-- Load Babel -->
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>