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
2020-08-11
Python | Reference
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
2020-08-11
Python | Pandas
2020-08-10
Minecraft | Server Properties
2020-07-21
Minecraft | MineOS
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 git
bundleVersion="$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
2020-06-29
Blender | Reflective Surface
2020-06-29
Blender | Navigation
2020-06-29
Blender | Materials
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
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
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.
- 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
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
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