Roses are red, forests are green …

https://pixabay.com/en/trump-us-president-usa-policy-1822121/

Creative commons

“I was with the president of Finland and he said: ‘We have, much different, we are a forest nation.’ He called it a forest nation. And they spend a lot of time on raking and cleaning and doing things, and they don’t have any problem.”

 

https://www.theguardian.com/us-news/2018/nov/19/make-america-rake-again-finland-trump-forest-fire

The internet mocks Trump for saying ‘raking’ forest floors would prevent California wildfires

Posted in allegedly, Covfefe | Comments Off on Roses are red, forests are green …

more fun with datatables

I actually don’t get a chance to do much GUI development but I did get a short stint on a project that used datatables.  It is actually fascinating just how much of a facelift this does give your standard HTML.  I did a small example of this in my blog entry software development the easy way.

Between normal javascript and datatables it is possible to actually make web applications that have a feel of your standard windows heavy client application.

The only example I have to share today is the ability to do a bit more with datatables.  In this case the need was to add totals of the contents of the table as a summary line.  This isn’t so difficult if you already know what the total is but if you do not there is a small bit of code that will do the calculation for you.

         function intVal ( i ) {
		return typeof i === 'string' ?
		i.replace(/[\$,]/g, '')*1 :
		typeof i === 'number' ?
         		i : 0;
            };

	$(document).ready(function() {
	   $('#example').DataTable( {
           "footerCallback": function ( row, data, start, end, display ) {
            var api = this.api(), data;

            var ageTotal = api
         	.column( 3 )
		.data()
       		.reduce( function (a, b) {
             return intVal(a) + intVal(b);
             }, 0 );
         
             ageTotal = Number(ageTotal).toFixed(2);
             ageTotal = ageTotal.toLocaleString();
         
             $( api.column( 3 ).footer() ).html(Number(ageTotal).toLocaleString());
	   },

If you add this code, actually not much different than many other examples on the internet to your web site then all of a sudden you will see your footer change with the new value(s).

The code is not all that difficult to follow.  You can use this particular function to put any values that you wish into the table footer.  In my case it was a simple sum, but if you needed some fancy algorithm then this would be the place to put it.

Download source for this example

Download files

 

Posted in programming | Comments Off on more fun with datatables

Internet of things

Now is a truly amazing time to be involved with computers and computing in general. With the networking moving from computers to smart phones to everything else we might finally see some pretty smart houses of the future today.

So far I haven’t done very much of my own to create any of my own IoT devices.  In the past I have taken a small step in this direction.  I created a small light fixture that can be controlled from my computer.

Home lighting solution

http://blog.paranoidprofessor.com/index.php/2016/12/28/evolution-of-led-lighting/

http://blog.paranoidprofessor.com/index.php/2017/01/03/evolution-of-led-lighting-hardware-and-tools/

http://blog.paranoidprofessor.com/index.php/2017/01/08/evolution-of-led-lighting-software-solution/

Fun with LEDS

http://blog.paranoidprofessor.com/index.php/2016/09/24/just-making-it-a-4x4x4-led-cube/

http://blog.paranoidprofessor.com/index.php/2017/06/16/just-making-it-revisiting-my-cube/

I have actually created my own device that will play streaming audio from the internet. The sum of the parts (raspberry pi, Linux, open source software) is much greater than the individual parts.

Not only have I managed to create my own device but I have also managed to get it published in the Linux Magazine issue #203.  You can download that particular article from Linux Magazine at the following link.

Bedtime Music

Even better than that go and purchase the entire magazine.

Posted in programming | Comments Off on Internet of things

safe computing – passwords

Have you ever done something despite the knowledge that it isn’t really safe?  This generic sentence could be anything from jaywalking to unprotected sex.

In my case, the situation is perhaps a both more mundane and a 21st century problem.  I do have quite a few email accounts that are used for different purposes.  One of the ones that I used to catch spam should know better when it comes to security.

This login dialog looks very similar to many other login dialogs.  The only interesting part is the checkbox “Angemeldet bleiben” which simply means that your user will stay logged in.  This is not an unsurprising feature for personal email accounts.  If this value is stored on the computer or with the account it would make perfect sense.

The insecure thing is that every time you go to this site this value is set to true.  By default, your credentials will be stored on the computer, not a problem if this is your computer at home but an extremely poor policy if the computer is public used.

A proper solution

It is not a good solution to store the password or some token in a cookie on your computer.  A much better solution would be to have the password memorized and use it each time.  It is possible to keep a few passwords in your head but after a while, the number starts to exceed the memory of even the best person.

Of course, it is possible to scribble your password on a sticky note or write it down in your notepad but if security is truly a requirement then storing the password list in an encrypted file is the best solution.

Keepassx

There are a lot of password managers that are available – it must be true as when I googled “password manager” it returned 480,000,000.  There may not be that many but there are easily dozens of free and commercial versions in the Google Play store alone.

Basically a password manager, sometimes referred to as a password safe is just a small application that collects passwords not too dissimilar to an address book for email addresses.

The real trick is not finding a password manager that runs on your phone but one that fits how you best operate. In my case that was a password manager that is truly multi-platform.  The usability of my password manager, Keepassx, is just fine on my smartphone.

Multiplatform does not have to be a requirement.  The only time I really wanted a multiplatform was when I had too many passwords and wanted to restructure how they were grouped.

The reason that I ended up deciding on keepassx was it was possible to install the app on my smartphone but also to install the application on my Linux Mint installation.

It is possible to create a folder structure separate different aspects of your passwords.  It is also possible to store any other important number.

It is possible to create entries to store the simple user and password.

Keepassx has been made flexible enough to allow adding other values as attributes.

Finally, it is possible to assign cute little icons to your entries and folders.  This is not just a fun feature but makes it possible to visually see which types of entries contain what types of data.

I cannot recommend this software enough.  it is easy to use on your phone but it also possible to copy the keepassx database to your computer and edit it without any difficulties.

https://community.linuxmint.com/software/view/keepassx

 

Posted in security | Tagged | Comments Off on safe computing – passwords

A binary converter

I’m a hobbyist programmer and I program mainly in python, but am learning Ruby,which is similar to python. In this post I’m going to show you a simple python program:

#program loop
while True:
#input
    userinput = int(input('Which decimal integer would you like converted to binary?'))
#processing
    if userinput == 0:
        print('0')
        continue
    else:
        binary = ''
        while int(userinput) > 0:
            digit = str(userinput % 2)
            userinput = userinput / 2
            binary = digit + binary
    #output
    print(binary)

Can you guess what this does? If you guessed that it converts decimal numbers to binary numbers, you’re correct. I’ll be explaining how it does that now. If you want to try this program yourself you have to use python 3. I will be breaking the code up into little pieces and explain what they do.

INPUT

First lets start with the part marked as input. All it really does is ask you the question: “Which decimal integer would you like converted to binary?” and sets the variable “userinput” to the response of the user to that question.

PROCESSING

1. It checks if the value “userinput” is equal to zero.    if userinput == 0:

1a.The program prints 0.  print(‘0’)

1b.The program skips to the next loop.    continue

2. It does the following steps if “userinput” wasn’t equal to zero.    else:

2a. It prepares following steps by creating a variable called “binary” and setting it’s value to a blank string.    binary = ‘ ‘

2b. It will loop these statements as long as “userinput” is positive.                             while int(userinput) > 0:

~this statement sets the variable “digit” to the mod (the remainder) but as a string.    digit = str(userinput % 2)

~this step divides “userinput” by 2.    userinput = userinput / 2

~the last step of the loop puts the variable “digit” in front of binary.                            binary = digit + binary

OUTPUT

The output step doesn’t do much. It just prints the “binary” value.


TERMS

variable: an interchangeable value

algorithm: a sequence of commands

function: a kind of command

PYTHON COMMANDS

#something –> This is a comment. It will not be read by python. You can obviously put in anything for “something”

while a == b: –>This is a loop it will loop through the algorithm that come after it as long as the statement after the while is true.

examplevariable = 1 –>This command sets a value to a variable.

Posted in programming, Python | Tagged | Comments Off on A binary converter

WoW = World of Warcraft Part 2

Hi last time we talked about the classes. This time we will talk about races in the alliance and horde. As races the alliance has :

  • Void Elf
  • Lightforged Dranei
  • Dark Iron Dwarf
  • Kul Tiran Humans

As races the horde :

  • Nightborne
  • Highmountain Tauren
  • Zandalari Troll
  • Mag´har Orc
Posted in Gaming | Comments Off on WoW = World of Warcraft Part 2

WoW = World of warcraft part 1

hi now i would like to talk about World of Warcraft.I personally also play world of Warcraft i am a Hunter. He´s a dps = damage per second there are also tanks. If you´re in a dungeon always stay behind the tank. And there are healers. Always stay in front of the healer. I personally love hunters and warlocks. There are also:

  • monks
  • death knights
  • mages
  • paladins
  • demon hunters
  • warriors
  • druids
  • rogues
  • shamans

Which character do you like? And do you like World of Worcraft?

Posted in Gaming, programming | 3 Comments

Chasing the little green lock

I wanted for the longest time to both convert this blog from http to https. Computers are ever more powerful and my site is pretty simple – it should not have been a big deal.  Not only that but with the rise of the firm Let’s Encrypt whose mission is to make encrypted connections to the World Wide Web ubiquitous.

Yet, I was not certain how to configure my site to use the certificate from Let’s Encrypt – because of that I procrastinated again and again.  I may have never done it except for Google’s desire to see this happen.  I did write about that not that long ago in ‘The carrot and the stick‘.

I was lucky that my ISP actually had done the work and by doing a bit of configuration using their GUI my web server now supported secure http.   The process was a bit of trial and error so I didn’t write about it.

It was only recently, well like today, that I realized my journey is not yet done.  I have a certificate but my website is not exactly trusted by Firefox or Google Chrome.

Firefox suggests that the problem is that the connection will only be partially encrypted.  This was also clarified as perhaps the images were the culprit. I have spent some time changing my image references from http to https but have not yet had much luck.

I will be continuing to try and get perfect security on this site and will keep you all informed of my progress as it occurs.

Posted in programming, security | Tagged , , | Comments Off on Chasing the little green lock

ripping compact discs to audio files

Perhaps it is not necessary for another article about how to convert cd’s to a format that can be used on our mp3 or ogg music players.  I have used k3b program for extracting ogg files in the past.

I suspect that there are also a number of similar programs on the windows side that are just as easy to use.  I would have used this method but I had a small stack of disc’s that needed to be ripped and I would prefer to just kick off a command line to do the task.

There already exists a fabulous script called “abcde” for doing most of this work.  This script extracts the audio data as wav data and then uses the desired codec for converting this wav data into the new format (ie mp3 or ogg).

The abcde script also downloads the names of the songs as well as the album art (for abcde version 2.7 and higher).

I knocked together the following script which will extract either ogg or mp3 files and rename the temporary directory into the name of the album.  By default, this script will call abcde and convert the ripped files to ogg format.  If this script is called with mp3 it will then rip the files and convert them to mp3.

FORMAT=ogg
if [ $# -eq 1 ]
then
   FORMAT=$1
fi

TMPDIR=abcde.`cd-discid | sed 's/ .*//'`

abcde -N -g -d /dev/sr0 -a read,encode,tag,getalbumart,clean -o $FORMAT -x

cd $TMPDIR

CNT=$((`cat cddbchoices | wc -l` - 2))
IDX=1

while [ $CNT -gt 1 ]
do
  TRACK=`tail -$CNT cddbchoices | head -1`
  TRACK=`echo $TRACK | sed 's/^..: //'`
  TRACK=`echo $TRACK | sed 's/^.: //'`

  TRACK=`echo $TRACK | sed 's/ /_/g' | sed 's/[^a-zA-Z0-9_-]//g'`

  FILENAME=$IDX
  if [ $IDX -lt 10 ]
  then
    FILENAME=0$IDX
  fi

  DEST_FILENAME="$FILENAME - $TRACK.$FORMAT"
  SRC_FILENAME=track${IDX}.$FORMAT

  if [ -f $SRC_FILENAME ]
  then
     echo mv "$SRC_FILENAME" "$DEST_FILENAME"
     mv "$SRC_FILENAME" "$DEST_FILENAME"
  fi

  CNT=$(($CNT - 1))
  IDX=$(($IDX + 1))
CNT=1
done

ALBUM=`head -2 cddbchoices | tail -1 | sed 's/ /_/g' | sed 's/[^a-zA-Z0-9_]//g'`
ALBUM=`echo $ALBUM | sed 's/^_//g'`
ALBUM=`echo $ALBUM | sed 's/_$//g'`

cd ..
mv $TMPDIR $ALBUM
echo $ALBUM

To be honest all of this scripting should be unnecessary.  Logic exists for doing all of this for you.  Simply change the configuration file to select the output format.

The standard configuration file /etc/abcde.conf allows for a lot of individual configuration.  Simply uncomment the OUTPUTFORMAT variable and change it to fit your needs.

#OUTPUTFORMAT='${ARTISTFILE}-${ALBUMFILE}/${TRACKNUM}.${TRACKFILE}'

For reasons unknown, this didn’t work for me.  Nor did creating a configuration file .abcde.conf in my home directory.

There is a lot information on the internet about how to use or configure and use this utility.

http://www.andrews-corner.org/linux/abcde/index.html

https://www.mankier.com/1/abcde

One of the more interesting things about the abcde script is that you can create multiple output files at the same time.  It is possible to create both mp3 and ogg files at the same time.  If both types of files are required then this is actually the fastest way to convert into both types of data.

Simply create a list of all formats when running the script.

-o mpg,ogg

Note: After writing this small script I discovered it didn’t work.  Well, it worked just fine for CD’s that only had one IMDB entry.  Even not using my script, the abcde script is fabulously useful.

Posted in programming | Tagged , | Comments Off on ripping compact discs to audio files

software development the easy way …

Is there really an easy way for software development?  Over time there has been an increasing number of different attempts at providing the silver bullet to faster better development.  The solutions have ranged from the tools such as adding syntax highlighting to editors, code generation and even fancy integrated development environments.

In one sense, software development is not a boring field as there is a constant addition of new languages and tools.

Back in the day, I was not terribly interested in designing web pages so I kept focused on developments in more traditional computing.  The goal to improve the lot of internet people everywhere continued without me.  It started with the creation of javascript (in 95) and later the creation of jquery(06) actually did make the task of javascript and HTML development easier.

The syntax for creating a table is actually really simple.  You can create a header and footer, if you are really clever you can use the footer to display totals.

<table id="example" class="display" style="width:100%">
 <thead>
  <tr>
    <th>Name</th> 
    <th>Position</th> 
    <th>Start date</th> 
    <th>End date</th> 
    <th>days in office</th> 
 </tr>
 </thead>
 <tfoot>
  <tr>
    <th>Name</th> 
    <th>Position</th> 
    <th>Start date</th>
    <th>End date</th> 
    <th>days in office</th> 
 </tr>
 </tfoot>

But the result of the simple html table is really really boring as well as feature poor.

Yet, there has been additional work to help make the process easier – especially when working with tables.  This solution comes in the form of additional javascript libraries.  These datatables  libraries (yup there are more than one) are available from datatables.net.

They are actually like magic.  With simply adding the tiniest amount of code you can get fully functional tables that look good and are very feature rich.

All that is necessary is the addition of the following table definition.

<script>
   $(document).ready(function() {
      $('#example').DataTable( {
      });
   } );
</script>

It is possible to define how many lines are displayed at one time, special buttons for exporting excel or csv data as well as defining the location of the buttons.

<script>
   $(document).ready(function() {
      $('#example').DataTable( {
         "lengthMenu": [[7, 14, 28, -1], [7, 14, 28, "All"]]
         ,"dom": '<"top"l>rt<"bottom"Bip>'
         ,buttons: [
         'copyHtml5','excelHtml5','pdfHtml5', 'csvHtml5', 'print'
      ]
      });
   } );
</script>

 

This is just a tiny piece of what functionality is possible using this datatables library.  Displaying a table is pretty tame.  It is possible to make the table editable.  This actually makes it possible to create “proper” applications inside your browser.

I am hoping to do a few blog postings showing off how powerful this library is.

Posted in programming | Comments Off on software development the easy way …