UNIX | Disk Usage

> du -sh *

2022-03-23

Mathematica | Solve

2021-11-22

RaspberryPi | IP Address

> ip addr show

2021-09-08

RaspberryPi | System Specs

> pinout

2021-07-23

RaspberryPi | Update

> sudo apt update
> sudo apt dist-upgrade
> sudo apt clean
> sudo reboot

2021-06-16

Python | Keywords

False class finally is return
None continue for lambda try
True def from nonlocal while
and del global not with
as elif if or yield
assert else import pass
break except in raise

2021-04-20

UNIX | VM Shared Folder

> sudo apt update> sudo apt install open-vm-tools open-vm-tools-desktop

> sudo mkdir -p /mnt/hgfs

Mount Immediately

> sudo mount -t fuse.vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other

Auto Mount
Add to /etc/fstab

.host:/ /mnt/hgfs fuse.vmhgfs-fuse auto,allow_other 0 0

*note - can now specify auto, don't need rc.local

https://gist.github.com/darrenpmeyer/b69242a45197901f17bfe06e78f4dee3

2021-03-15

Docker | Commands

> docker ps
> docker container ls
> docker system df

> docker exec -it \ /bin/bash

Cleanup

> docker system prune
> docker system prune --volumes

> docker system df

> docker images

2020-09-17

Python | Profiler

python -m cProfile -s cumtime exporter.py 48 > profile.txt

2020-09-07

Python | Data Structures

Dictionaries

dictionary = { "A": 1, "B": 2, "C": 3 }

x = dictionary["A"]
dictionary["A"] = 10

for x in dictionary: print(x) # Keys

for x in dictionary.values(): print(x) # Values

if "A" in dictionary: print("Yes")

dictionary["D"] = 4

dictionary.pop("D")

Lists

https://docs.python.org/3/tutorial/datastructures.html

2020-09-06

Git | Rename and Move Files

Run from the command line:

> git mv oldfilename newfilename
> git commit --message 'Renamed oldfilename to newfilename'

2020-09-03

Miscellaneous | SQL Server

https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/back-up-and-restore-of-sql-server-databases?view=sql-server-ver15
https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/create-a-full-database-backup-sql-server?view=sql-server-ver15
https://support.microsoft.com/en-us/help/2019698/how-to-schedule-and-automate-backups-of-sql-server-databases-in-sql-se
https://docs.microsoft.com/en-us/sql/t-sql/statements/backup-transact-sql?redirectedfrom=MSDN&view=sql-server-ver15

https://www.sqlshack.com/understanding-sql-server-backup-types/

Backup:
https://stackoverflow.com/questions/487675/how-can-i-schedule-a-daily-backup-with-sql-server-express
https://stackoverflow.com/questions/880487/sql-server-command-line-backup-statement/29893738#29893738
https://stackoverflow.com/questions/493886/sql-server-automated-backups/493952#493952

Docker:
https://www.microsoft.com/en-us/sql-server/developer-get-started/python/mac
https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-ver15
https://cloudblogs.microsoft.com/sqlserver/2017/04/03/sql-server-command-line-tools-for-mac-preview-now-available/
https://docs.microsoft.com/en-us/sql/linux/tutorial-restore-backup-in-sql-server-container?view=sql-server-ver15
https://www.sqlshack.com/working-sql-server-command-line-sqlcmd/

2020-08-11

Python | Reference

https://www.w3schools.com/python/default.asp
https://www.geeksforgeeks.org

Homebrew & Docker:
https://discourse.brew.sh/t/installing-python-components-on-a-mac/4610
https://docs.python-guide.org/dev/virtualenvs/
https://pipenv-fork.readthedocs.io/en/latest/install.html

2020-08-11

Python | More Pandas

Excel Export:

df.to_excel('output.xlsx')

Accessing dataframe:

df.iloc[row,column]?
df.at(row, "Column Name")

2020-08-11

Git | More Git

Recursively add the entire folder to a repository

Check the .gitignore file, if the subdirectory is ignored.

git add --all
git commit -m ""
git push

https://stackoverflow.com/questions/17743549/recursively-add-the-entire-folder-to-a-repository

2020-08-11

Docker | Documentation

https://docker-curriculum.com

2020-08-11

Python | Pandas

https://pandas.pydata.org/pandas-docs/stable/reference/index.html

Openpyxl
https://openpyxl.readthedocs.io/en/stable/index.html

2020-08-10

Minecraft | Server Properties

https://minecraft.gamepedia.com/Server.properties

2020-07-21

Minecraft | MineOS

Server software for running multiple concurrent Minecraft servers.

https://minecraft.codeemo.com/mineoswiki/index.php?title=MineOS-node_(yum)https://minecraft.codeemo.comhttps://minecraft.codeemo.com/crux/comparison.html

2020-07-20

UNIX | User Management

Add User:

>su
>useradd exampleuser && passwd exampleuser

Delete User:

>su
>userdel exampleuser

Delete User and Remove Home Directory:

>userdel -r exampleuser

2020-07-19

Minecraft | Multiple Servers

SRV records:

Example:mc1.reliablesite.net > 1.2.3.4 port 25565
mc2.reliablesite.net > 1.2.3.4 port 25566
mc3.reliablesite.net > 1.2.3.4 port 25567

minecraft.tcp.name TTL class SRV priority weight port target
minecraft.tcp.mc1 3600 IN SRV 0 5 25565 minecraft.reliablesite.net

https://www.reliablesite.net/hosting-news/multiple-minecraft-servers-1-ip/#.XxTaRC2z125

2020-07-19

UNIX | FirewallD

Enable:

>sudo systemctl enable firewalld
>sudo reboot

Status:

>sudo firewall-cmd --state

Services:

>firewall-cmd --get-services

>sudo firewall-cmd --zone=public --add-service=http
>sudo firewall-cmd --zone=public --list-services

output
dhcpv6-client http ssh

>sudo firewall-cmd --zone=public --permanent --add-service=http

>sudo firewall-cmd --zone=public --add-port=5000/tcp
>sudo firewall-cmd --zone=public --add-port=4990-4999/udp

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-using-firewalld-on-centos-7

2020-07-18

Minecraft | Server RAM

Minecraft Server RAM flags

-XmxMaximum memory allocation pool for a Java virtual machine
-Xmsinitial memory allocation pool-Xmn?

2020-07-15

ADC | Modal Open and Save Dialogs

Mac Open and Save Modal Dialogs

Open

let panel = NSOpenPanel()

panel.allowsMultipleSelection = false
panel.canChooseDirectories = false
panel.canCreateDirectories = false
panel.canChooseFiles = true

// "OK"
if (panel.runModal() == NSApplication.ModalResponse.OK) {
let result = panel.url

if (result != nil) {    let path: String = result!.path}

// "Cancel"
} else {
return
}

Save

let panel = NSSavePanel()

panel.nameFieldStringValue = fullName
panel.canCreateDirectories = true

// "Save"
if (panel.runModal() == NSApplication.ModalResponse.OK) {
let result = panel.url

   if (result != nil) {       let path: String = result!.path   }

// "Cancel"
} else {
return
}

https://ourcodeworld.com/articles/read/1117/how-to-implement-a-file-and-directory-picker-in-macos-using-swift-5
https://developer.apple.com/documentation/appkit/nsopenpanelhttps://developer.apple.com/documentation/appkit/nssavepanel
https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/UsingtheOpenandSavePanels/UsingtheOpenandSavePanels.html

2020-07-07

ADC | Xcode Git & Build Number

Script to add to Xcode's Target "Build Phases".
Create a "Set Build Number" phase after "Dependencies".
Add this shell script:

GIT

# Set build number to number of git commits
commits=$(git rev-list HEAD | wc -l | tr -d ' ')
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $commits" "${PROJECTDIR}/${INFOPLISTFILE}"

Reference Versions:

#Update build number with number of git commits if in release modeif [ ${CONFIGURATION} == "Release" ]; thenbuildNumber=$(git rev-list HEAD | wc -l | tr -d ' ')/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECTDIR}/${INFOPLISTFILE}"fi;

git=sh /etc/profile; which gitbundleVersion="$git" rev-list --all |wc -l/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $bundleVersion" "${TARGETBUILDDIR}/${INFOPLIST_PATH}"

#!/bin/bash

git=$(sh /etc/profile; which git)numberofcommits=$("$git" rev-list HEAD --count)gitreleaseversion=$("$git" describe --tags --always --abbrev=0)

targetplist="$TARGETBUILDDIR/$INFOPLISTPATH"dsymplist="$DWARFDSYMFOLDERPATH/$DWARFDSYMFILE_NAME/Contents/Info.plist"

for plist in "$targetplist" "$dsymplist"; do if [ -f "$plist" ]; then /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $numberofcommits" "$plist" /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${gitreleaseversion#*v}" "$plist" fidone

SVN (Old version used for SVN)

REV=svnversion -nc | /usr/bin/sed -e 's/^[^:]*://;s/[A-Za-z]//'/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $REV" "${INFOPLIST_FILE}"

https://blog.curtisherbert.com/automated-xcode-build-numbers-early-2019-edition/
https://objcsharp.wordpress.com/2013/10/01/how-to-automatically-update-xcode-build-numbers-from-git/https://www.mokacoding.com/blog/automatic-xcode-versioning-with-git/
https://fuller.li/posts/versioning-with-xcode-and-git/

2020-07-01

Blender | Sphere

Blender

To make a sphere round:

Turn on "Smooth Shading"

Add vertices/subdivide

https://blender.stackexchange.com/questions/2773/how-can-i-make-a-circular-object-appear-perfectly-round

2020-06-29

Blender | Reflective Surface

Blender

To make a surface reflective:

Set metallic to 1

Roughness to 0

https://blender.stackexchange.com/questions/93294/make-a-reflective-surface/93459

2020-06-29

Blender | Navigation

Blender

Pan: SHIFT
Zoom: CONTROL

https://docs.blender.org/manual/en/latest/editors/3dview/navigate/navigation.html

2020-06-29

Blender | Materials

Blender

Uses "Principled BSDF" materials?

Based on Pixar’s Renderman?

https://docs.blender.org/manual/en/latest/render/shader_nodes/shader/principled.html

2020-06-29

Blender | Spot Light

Blender

To have a light track an object, add a "Track to" constraint.

Set

To= -Z

Up = Y

https://blender.stackexchange.com/questions/43497/pinpoint-the-area-light-to-object

2020-06-23

Git | Git for Website Management

How to configure Git for web management.

References:
https://rogerdudler.github.io/git-guide/

https://gist.github.com/Nilpo/8ed5e44be00d6cf21f22
https://blog.sebduggan.com/2012/03/13/deploy-your-website-changes-using-git/
http://nicolasgallagher.com/simple-git-deployment-strategy-for-static-sites/
https://toroid.org/git-website-howto

https://git-scm.com/docs/git-push
.gitignore
https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository#_tracking_files

https://www.digitalocean.com/community/tutorials/how-to-install-git-on-centos-7
https://gitlist.org
https://gofedora.com/insanely-awesome-web-interface-git-repos/
https://wiki.archlinux.org/index.php/Gitweb
https://git-scm.com/book/en/v2/Git-on-the-Server-GitWeb
https://gofedora.com/how-to-install-configure-gitweb/
https://httpd.apache.org/docs/2.4/howto/auth.html

https://www.atlassian.com/git/tutorials/syncing
https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-init

2020-05-27

UNIX | Linode CentOS Setup

How to configure CentOS on Linode.

  • Configure CentOS

    Update:> yum update

    Hostname:
    > hostnamectl set-hostname example_hostname

    Hosts File:
    /etc/hosts

    Timezone:
    >timedatectl set-timezone 'America/New_York'

    Add User:
    >useradd exampleuser && passwd exampleuser
    >usermod -aG wheel example_user

    Disable SSH root login:
    /etc/ssh/sshd_config
    # Authentication:
    ...
    PermitRootLogin no

  • Install Apache

    Update:
    >sudo yum update

    Install Apache:
    >sudo yum install httpd

    Enable and start Apache:
    >sudo systemctl enable httpd.service
    >sudo systemctl start httpd.service

    >sudo nano /etc/httpd/conf.modules.d/httpd-mpm.conf
    KeepAlive Off

    \
    StartServers 4
    MinSpareServers 20
    MaxSpareServers 40
    MaxClients 200
    MaxRequestsPerChild 4500
    \

    Backup httpd.conf>sudo cp /etc/httpd/conf/httpd.conf httpd.conf.backup

    Virtual Hosts:

    >sudo mkdir /etc/httpd/conf/vhosts

    >sudo nano /etc/httpd/conf/httpd.confIncludeOptional vhosts/*.conf

    >sudo apachectl configtest

    >sudo systemctl reload httpd.service

    * Another method is to create "avaliable-sites" and "enabled-sites" folders and symbolic link (ln -s) between them.

SELinux:

sudo chown apache:apache -R /var/www/html/example.com/

cd /var/www/html/example.com/find . -type f -exec sudo chmod 0644 {} \;find . -type d -exec sudo chmod 0755 {} \;

sudo chcon -t httpdsyscontentt /var/www/html/example.com -Rsudo chcon -t httpdsysrwcontent_t /var/www/html/example.com -R

sudo systemctl enable httpd.servicesudo systemctl restart httpd.service

Firewall:sudo firewall-cmd --zone=public --list-services

sudo firewall-cmd --zone=public --add-service=http --permanentsudo firewall-cmd --zone=public --add-service=https --permanentsudo firewall-cmd --zone=public --add-service=httpsudo firewall-cmd --zone=public --add-service=https

References:
https://www.linode.com/docs/getting-started/
https://www.linode.com/docs/security/securing-your-server/
https://www.linode.com/docs/web-servers/lamp/how-to-install-a-lamp-stack-on-centos-8/

2020-05-08

UNIX | SELinux & Apache

How to configure SELinux for Apache virtual hosts on CentOS.

  • Need to install "semanage"

    Name of package needed:
    > yum provides *bin/semanage

    Install:
    > yum install -y policycoreutils-python-utils

    Optional:
    > yum install -y setroubleshoot

  • Context types for Apache

    Read-only:
    httpd_sys_content_t

    Read and write:
    httpd_sys_rw_content_t

    Log files:
    httpd_log_t

  • SEManage commands

    > semanage fcontext -a -t httpd_sys_content_t "/var/www/testsite/public(/.*)?"
    > semanage fcontext -a -t httpd_log_t "//var/www/testsite/logs(/.*)?"

    > restorecon -Rv /webapps
    > ls -lZ /webapps

    > restart apache

References:
https://www.serverlab.ca/tutorials/linux/web-servers-linux/configuring-selinux-policies-for-apache-web-servers/
https://wiki.centos.org/HowTos/SELinux

2020-05-07

Python | Python Basics

The Python Tutorial

Numbers
/ - "Classic Division" returns a float
// - "Floor Division" returns the fractional part
% - Returns the remainder

** - Calculates powers

Full floating point support, integers are automatically converted

Strings
"" and '' are the same.\ - escapesr"" or r'' - "Raw" string doesn't interpret special characters."""...""" or '''...''' - Triple-quotes let strings span more than one line.

    • Concatenates
    • Repeats (e.g. 3 * 'un' + 'ium' >>> unununium)

Two or more string literals are automatically concatenated (e.g. 'Py' 'thon' >>> 'Python')

Strings are automatically indexed and ranges are possible
word = 'Python'
word[0] >>> 'P'
word[5] >>> 'n'
word[-1] >>> 'n'
word[0:2] >>> 'Py'
word[2:5] >>> 'tho'
word[:2] >>> 'Py'
word[4:] >>> 'on'

+---+---+---+---+---+---+
| P | y | t | h | o | n |
+---+---+---+---+---+---+
0 1 2 3 4 5 6
-6 -5 -4 -3 -2 -1

Python strings are immutable.

len(string) returns length of the string.

Lists
Lists are mutable.
squares = [1, 4, 9, 16, 25]
squares[0] = 10 >>> [10, 4, 9, 16, 25]
Lists support concatenation.
squares + [36, 49, 64, 81, 100] >>> [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
Len even works. len(squares) >>> 5

2020-04-14

Miscellaneous | Markdown

https://daringfireball.net/projects/markdown/syntax
https://www.markdownguide.org/basic-syntax/

2020-04-10

Git | Git

  • To have .git repository out of Public, do git init in the parent folder and only add the Public folder.

  • Multiple repositories are easy, git just traverses up the directory tree until it finds .git.

  • Do operations on specific .git repository anywhere underneath .git directory.

  • Git stores the repository in the .git folder where you do git init. Add to the repository at the same level or below.

References:
Using Git to manage a website:
https://gist.github.com/Nilpo/8ed5e44be00d6cf21f22
https://blog.sebduggan.com/2012/03/13/deploy-your-website-changes-using-git/
http://nicolasgallagher.com/simple-git-deployment-strategy-for-static-sites/
https://toroid.org/git-website-howto

Pull from another repository without history
https://stackoverflow.com/questions/28932990/git-pull-from-another-repository-without-history

2020-04-09

Git | Git Basics

> git init
> git add {files}
> git commit -m 'Project Start'

References:
Simple Git
https://rogerdudler.github.io/git-guide/

https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository
https://rogerdudler.github.io/git-guide/

2020-04-07

Miscellaneous | CSS

  • * affects all tags
  • p tags use margin to get their spacing
  • If you set margin=0 in *, p tags don't space.
2020-04-02