"Recently, I had a situation where I needed to execute multiple programs in Linux at the same time while redirecting their outputs to separated log files and wait for them to finish.
If you ever need to do something like that, I leave year the script that I used to accomplish that task:"
#!/bin/bash
# Add the full path processes to run to the array
PROCESSES_TO_RUN=("/home/joao/Code/test/prog_1/prog1" \
"/home/joao/Code/test/prog_2/prog2")
# You can keep adding processes to the array...
for i in ${PROCESSES_TO_RUN[@]}; do
${i%/*}/./${i##*/} > ${i}.log 2>&1 &
# ${i%/*} -> Get folder name until the /
# ${i##*/} -> Get the filename after the /
done
# Wait for the processes to finish
wait
As you all know a software license is something that tells the users what they can or cannot do with that especific software and it's also a way of giving some credit to the author for his software.
There are several types of licenses:
- Perpetual license
- Subscription license
- Freeware license
- Shareware license
- OEM (original equipment manufacturer)
- Educational or Academic Software
- Not for Resale (NFR) Software License
- And more...
This post is specifically about Freeware Licences and specially about Open Source because, as you already know, inside free software applications we have some that are open source and others that are closed source.
So let's see a little bit more about free and open source software (quoting Wikipedia.org):
A primary consequence of the free software form of licensing is that
acceptance of the license is essentially optional — the end-user may
use, study, and privately modify the software without accepting the
license. However, if the user wishes to exercise the right of
redistributing the software, then the end-user must accept, and be bound
by, the software license. Free and open-source licenses generally fall under two categories:
Those with the aim to have minimal requirements about how the software
can be redistributed (permissive licenses),
and those that aim to preserve the freedoms that is given to the users
by ensuring that all subsequent users recives those rights (copyleft Licenses). An example of a copyleft free software license is the GNU General Public License
(GPL). This license is aimed at giving all user unlimited freedom to
use, study, and privately modify the software, and if the user adheres
to the terms and conditions of GPL, freedom to redistribute the software
or any modifications to it. For instance, any modifications made and
redistributed by the end-user must include the source code for these,
and the license of any derivative work must not put any additional
restrictions beyond what GPL allows.[1] Examples of permissive free software licenses are the BSD license and the MIT license,
which give unlimited permission to use, study, and privately modify the
software, and includes only minimal requirements on redistribution.
This gives a user the permission to take the code and use it as part of
closed-source software or software released under a proprietary software license.
One of the most known and used license for this type of software is the GNU GPL(General Public License) that is now on version 3. The bases of this license, quoting gnu.org, are:
The Foundations of the GPL
Nobody should be restricted by the software they use. There are four
freedoms that every user should have:
the freedom to use the software for any purpose,
the freedom to change the software to suit your needs,
the freedom to share the software with your friends and neighbors, and
the freedom to share the changes you make.
When a program offers users all of these freedoms, we call it free
software. Developers who write software can release it under the terms of the GNU
GPL. When they do, it will be free software and stay free software, no
matter who changes or distributes the program. We call this copyleft: the
software is copyrighted, but instead of using those rights to restrict
users like proprietary software does, we use them to ensure that
every user has freedom.
So if you developed a software and you are thinking about distributing it as a free software, i created a little video explaning what you need to do to license your software with GNU GPL v3. I am not an expert on this but i have already done this and i am just trying to share my experience.
This tutorial it's about reading a file line by line until the end in VB.NET. This is usefull, for instance, if you are using this file as a settings file and you inserted one setting per line then you can read them by order.
Visual Studio screenshot:
Code:
Imports System.IO Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim file_dir As String = "file.txt" 'parse file Try Dim sr As StreamReader = New StreamReader(file_dir) Do Until sr.EndOfStream TextBox1.Text += vbNewLine + sr.ReadLine() Loop sr.Close() Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub End Class
In this case you are reading and adding each line to a textbox but you can read this to a string array and keep the information to work with later. It's also important to use try catch because if the file doesn't exist or you don't have permissions to read it will not crash the application.
Let's imagine that you hava a textbox for a user to input something and you want that to be between a minimum and a maximum number of characters, how you do it on VB.NET? Let's see!
Code:
Maximum size limitation can be done in the textbox properties in the "MaxLenght" option.
To minimum size limitation it's only necessary to check when user clicks the button to send that information.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click check_text() End Sub
Private Sub check_text() If TextBox1.Text.Length = 3 Then MessageBox.Show("Ok") Else MessageBox.Show("You need to insert 3 numbers") End If End Sub
Sometimes we need to limit our user inputs to only numbers for instance in a quantity input and for that i leave here a tutorial on how to do that in VB.NET.
Code:
Public Class Form1 Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If (Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57) Or Asc(e.KeyChar) = 8 Then e.Handled = False Else e.Handled = True End If End Sub
This tutorial contains you the necessary code to check if a directory exists and to create one if it returns false using VB.NET.
Code:
Imports System.IO
If Directory.Exists("c:\mydir") Then MessageBox.Show("Directory exists!") Else Directory.CreateDirectory("c:\mydir") MessageBox.Show("Directory created!") End If
I needed to remember the syntax of the switch / case for the .net languages and then i decided to share them with you here too so you can learn or remember them too.
C#:
switch (option){case"option1":// code for case "option1"
break;case"option2"://code for case "option2" break;default://code for every other options
break;}
VB.NET:
SelectCaseoptionCase"option1"' code for case "option1"Case"option2"' code for case "option2"CaseElse' code for every other optionsEndSelect
Lots of people wounder how they can put thir website online without spending much money or no money at all. There are several way of doing that and Zymic is on of them. Zymic provides a free hosting service with the following caracteristics:
Free Web Hosting - General Features
- Disk Space 5000MB
- Data Transfer (Monthly) 50000MB
- Control Panel ZHCP
- Number Of Accounts Unlimited
- FTP Access Yes
- Advertisements No
Free Web Hosting - PHP And Databases
- PHP Ver 5.2.12
- MySQL Databases 3
- SQLBuddy Ver Custom
This is a quick tip on Java about inserting an image on a JFrame using a JLabel in Netbeans IDE. Since NetBeans don't give a direct way to insert images this is the best way to do it.
This tutorial presents two ways of order a vector using the programming language C.
We can use the typical way with two for cicles that can become really slow when the vector length is big (like 3555555) or a less commun way but a faster and smaller (in lines of code).
Typical way:
#include <stdio.h>
int main() { int v[5] ={2,5,3,2,4}; int v_temp; int i,j; for (i=0; i<5; i++) { for (j=0; j<5; j++) { if(v[i] <= v[j] && i!=j) { v_temp=v[j]; v[j]=v[i]; v[i]=v_temp; } } } for (i=0; i<5; i++) { printf("%d -> %d\n",i,v[i]); } return 0; }
int main() { int v[5] ={2,5,3,2,4}; int i; qsort(v, 5, sizeof(int), sort); /*less lines of code and way faster ordering the vector qsort(name_of_vector,length_of_vector,sizeof(type_of_variable),name_of_function) in this case name_of_function is "sort"*/ for (i=0; i<5; i++) { printf("%d -> %d\n",i,v[i]); } return 0; }