Or if that link breaks, use these settings in the JSON settings bit:
“telemetry.enableTelemetry”: false
“telemetry.enableCrashReporter”: false
Category Archives: Comp Sci
Adding a Weka shortcut under Fedora Linux
…and scaling it up for High DPI screens.
I’ve recently bought the developer edition of the XPS13 with a highDPI screen and needed to install WEKA for a course I’m doing. When I first ran it from the command line it looked like a tiny little thing in the top left of the screen however a small amount of DuckDuckGo-ing resulted in the correct way of dealing with it.
I’m using Fedora (and gnome) so create a Desktop file for Weka with this pasth and filename: ~/.local/share/applications/weka.desktop
I’ve put my weka jar file in a directory called Programs in my home folder.
[Desktop Entry] Type=Application Encoding=UTF-8 Name=Weka Comment=Weka Application Exec=java -Dsun.java2d.uiScale=3.5 -jar /home/mike/Programs/weka-3-8-1/weka.jar Icon=/home/mike/Programs/weka-3-8-1/weka.ico Terminal=false
Save it and you should be good to go. Make sure you have the Latest Java installed (I’m using Java9 straight from Oracle). Oh! change the uiScale factor to suite your preference.
Generating a SSH key and uploading it to a server
Generate a key with:
ssh-keygen -t rsa
When you are entering the values for the key, remember to set the name and path appropriately.
Upload the public part to your server using:
ssh-copy-id -i ~/.ssh/root_key.pub root@1.2.3.4
Whatever you set the name and path to in the ssh-keygen part you will need to make sure it replaces the ~/.ssh/root_key bit in the second command.
Now you can use rsync to seamlessly copy files from one computer to another
rsync -avz --progress /home/person1/DirectoryOrFile person2@1.2.3.4:/home/person2/DirectoryOrFile
…so that’s:
rsync -avz --progress username@server:
GitLab Docker Container on Fedora 26 Server
I’ve set up a NUC in the house to replace a Digital Ocean droplet.
My first job was to set up a headless Fedora 26 server. Currently it’s running Nextcloud which I set up using instructions from: marksei.com, and a docker container with Gitlab on it, based on instructions from this site.
To get the docker container to run I sued the following code:
docker run --detach --hostname gitlab.my.domain --publish 1443:443 --publish 180:80 --publish 122:22 --name gitlab --restart always --volume /srv/gitlab/config:/etc/gitlab:Z --volume /srv/gitlab/logs:/var/log/gitlab:Z --volume /srv/gitlab/data:/var/opt/gitlab:Z gitlab/gitlab-ce:latest
Notice that the ports are translated to:
1443 from 443 (https)
180 from 80 (http)
122 from 22 (ssh)
…because I was already running https, http and ssh on the server.
mark the repo as the origin by going into the directory and using the following command for SSH
git remote add origin ssh://git@yourIPADDRESSorURL:122/monkeymike/MyGreatCodingProject.git
..or for http connections (using username and password – when pushing)
git remote add origin http://yourIPADDRESSorURL:180/monkeymike/MyGreatCodingProject.git
then push to it with:
git push -u origin --all
…and if you need to clear this:
git remote rm origin
If I want to connect to the docker container over SSH I use:
ssh git@myserverURL -p 122
..and when I connect to the server, front end, I use http://myserverURL:180 and it’s all good.
NuGet on Rider C# IDE from JetBrains
You can find NuGet under the Tools menu, then select NuGet and then Manage Nuget Packages.
Once you have the packages dialog open type in the name of the package, choose the package you want and use the green cross button (on the right hand side) to add it to your project.
That should add it to your project; nice and easy.
Moving Files By Name
…where the name is made up of the date and time.
I’ve got a lot of image files that I tend to dump into whatever directory I feel like.
This simple python script will create directories and move files around based on the file name, as long as the filename follows the following format YYYYMM
Notice I’m not checking for JPG/MP4 files only; I’m not checking that the year or month are valid values; I’m not checking the EXIF values and basing it on them if the filename is not valid; there are lots of really cool things I could do as well but I don’t need those because that’s how my files are set out. I’m not building in lots of features that don’t touch my use-case.
import os import shutil path = '/home/mike/TestPython/' os.chdir(path) for file in os.walk(path): for name in file[2]: year = name[:4] month = name[4:6] if name[:6].isdigit(): if not os.path.exists(year): os.makedirs(year) if not os.path.exists(year + "/" + month): os.makedirs(year + "/" + month) src = file[0] + "/" + name dst = path + year + "/" + month + "/"+name shutil.move(src, dst)
Once you’ve moved all the files into their new homes delete all the empty directories. This code has been ever so slightly modifed from this StakOverflow post. It was modified for Python 3, by adding brackets to the print syntax:
import os currentDir = '/home/mike/TestPython/' index = 0 for root, dirs, files in os.walk(currentDir): for dir in dirs: newDir = os.path.join(root, dir) index += 1 print (str(index) + " ---> " + newDir) try: os.removedirs(newDir) print("Directory empty! Deleting...") print(" ") except: print("Directory not empty and will not be removed") print(" ")
Minecraft Powered Minecart Collect and Deposit
This arrangement allows you to Empty on the right and send it to a box on the left.
Please note: On the collection point (right hand side) there is a Not Gate using a redstone torch.
Now that microsoft minecraft has stopped allowing you to mine mobs properly:
enable cheats then /gamerule maxEntityCramming 0
Some basic Linux commands
Ownership and access permissions for /var/www
chown -R mike:mike /var/www/ chmod -R 755 /var/www/
Simple Java Insertion Sort
package insertionshort; public class InsertionShort { public static void main(String[] args) { int[] a = {123, 235, 23, 46, 34, 2, 45, 235, 25, 65, 46, 2345, 25, 246, 24, 5246, 24, 6}; intInsertionSort(a); } public static void intInsertionSort(int[] a) { for (int i = 0; i < a.length; i++) { int temp = a[i]; int j; for (j = i - 1; j >= 0 && temp < a[j]; j--) { a[j + 1] = a[j]; } a[j + 1] = temp; for (int f = 0; f < a.length; f++) { System.out.print(a[f] + "\t"); } System.out.println(); } } }
Sorting Algorithms
Nice animations over at: sorting-algorithms