<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<title type="html"><![CDATA[Linux Lite Forums - Coding]]></title>
	<subtitle type="html"><![CDATA[Linux Lite Forums - https://www.linuxliteos.com/forums]]></subtitle>
	<link rel="self" href="https://www.linuxliteos.com/forums/syndication.php"/>
	<id>https://www.linuxliteos.com/forums/</id>
	<link rel="alternate" type="text/html" href="https://www.linuxliteos.com/forums/"/>
	<updated>2025-06-09T04:59:06Z</updated>
	<generator uri="https://mybb.com">MyBB</generator>
	<entry xmlns="http://www.w3.org/2005/Atom">
		<author>
			<name type="html" xml:space="preserve"><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=4985">navid_dada</a>]]></name>
		</author>
		<published>2022-01-14T14:58:39Z</published>
		<updated>2022-01-14T14:58:39Z</updated>
		<link rel="alternate" type="text/html" href="https://www.linuxliteos.com/forums/showthread.php?tid=8084" />
		<id>https://www.linuxliteos.com/forums/showthread.php?tid=8084</id>
		<title xml:space="preserve"><![CDATA[why does npm install encounter with permission denied error on LinuxLite?]]></title>
		<content type="html" xml:space="preserve" xml:base="https://www.linuxliteos.com/forums/showthread.php?tid=8084"><![CDATA[I am using LinuxLite V5 and I am trying to clone one repository from git using npm V8.3.0 but it throws this exception:<br />
<br />
    fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone7tt2X1': Permission denied<br />
<br />
I try all of these commands but no progress!!!<br />
<br />
    npm i -g <a href="https://github.com/nextcloud/strengthify" target="_blank" rel="noopener" class="mycode_url">https://github.com/nextcloud/strengthify</a><br />
<br />
    npm i <a href="https://github.com/nextcloud/strengthify" target="_blank" rel="noopener" class="mycode_url">https://github.com/nextcloud/strengthify</a><br />
<br />
    sudo npm i -g <a href="https://github.com/nextcloud/strengthify" target="_blank" rel="noopener" class="mycode_url">https://github.com/nextcloud/strengthify</a><br />
<br />
    sudo npm i <a href="https://github.com/nextcloud/strengthify" target="_blank" rel="noopener" class="mycode_url">https://github.com/nextcloud/strengthify</a><br />
<br />
    npm install --prefix=&#36;HOME/.local --global <a href="https://github.com/MorrisJobke/strengthify.git" target="_blank" rel="noopener" class="mycode_url">https://github.com/MorrisJobke/strengthify.git</a><br />
<br />
    sudo npm install --prefix=&#36;HOME/.local --global <a href="https://github.com/MorrisJobke/strengthify.git" target="_blank" rel="noopener" class="mycode_url">https://github.com/MorrisJobke/strengthify.git</a><br />
<br />
I also run all of these commands in sudo su mode but there was not any progress.<br />
<br />
I also checked folder owner and group and permissions. it is the result:<br />
<br />
    drwxrwxrwx 6 root root 4096 jun 13 14:50 .npm<br />
<br />
How can I solve this problem?]]></content>
		<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
	</entry>
	<entry xmlns="http://www.w3.org/2005/Atom">
		<author>
			<name type="html" xml:space="preserve"><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=4370">Kevin Perez</a>]]></name>
		</author>
		<published>2021-09-17T07:03:34Z</published>
		<updated>2021-09-17T07:03:34Z</updated>
		<link rel="alternate" type="text/html" href="https://www.linuxliteos.com/forums/showthread.php?tid=7935" />
		<id>https://www.linuxliteos.com/forums/showthread.php?tid=7935</id>
		<title xml:space="preserve"><![CDATA[Setup Valgrind]]></title>
		<content type="html" xml:space="preserve" xml:base="https://www.linuxliteos.com/forums/showthread.php?tid=7935"><![CDATA[Hey there everyone,<br />
<br />
Not sure how much information one needs to help me get Valgrind to be fully setup. If necessary, I will post the version of Linux Lite and Code::Blocks currently installed on my computer. HOpefully, what is included will be sufficient.<br />
<br />
I am currently using Code::Blocks as my compiler. I have created a simple project by the name of DynIntArray. in this project there are two classes:<br />
DynIntArray &amp; DynVoidArray. Each one has a dynamic array. In order to verify that my project is not leaking memory, I am hoping to use Valgrind. I have already installed it, but I now need to edit the bashrc file so it includes "export VALGRIND_LIB = '/usr/lib/valgrind'. Unfortunately, once I have opened the bashrc file to edit it, I am not sure how to save it. Furthermore, the video I was watching seems to be meant for Ubuntu rather than Linux Lite. How may I open, edit, and save the changes I wish to make to the .bashrc file? Hopefully, with some assistance, I can check to ensure the project is not leaking memory. <br />
<br />
Thank you for reading this post, and I very much look forward to reading your responses.]]></content>
		<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
	</entry>
	<entry xmlns="http://www.w3.org/2005/Atom">
		<author>
			<name type="html" xml:space="preserve"><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=4591">Zaid Ouardi</a>]]></name>
		</author>
		<published>2021-05-11T04:58:26Z</published>
		<updated>2021-05-11T04:58:26Z</updated>
		<link rel="alternate" type="text/html" href="https://www.linuxliteos.com/forums/showthread.php?tid=7769" />
		<id>https://www.linuxliteos.com/forums/showthread.php?tid=7769</id>
		<title xml:space="preserve"><![CDATA[how to install vscode on linux lite]]></title>
		<content type="html" xml:space="preserve" xml:base="https://www.linuxliteos.com/forums/showthread.php?tid=7769"><![CDATA[sudo apt install code <br />
Reading package lists... Done<br />
Building dependency tree       <br />
Reading state information... Done<br />
E: Unable to locate package code<br />
 <br />
I don't know why vs code isn't installing <br />
<br />
Note :I just installed linux lite as my first ever linux distro and i wanted to use it to learnto code and then contribute to open source projects (like: Linux lite and other linux distros + emulators).<br />
ANd i'm completely new to linux even thoughit's my favourite OS and i even watch dozens of linux related youtube videos.<br />
<br />
Plz i'm asking help from the wonderful community of Linux lite and LINUX in general.<br />
]]></content>
		<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
	</entry>
	<entry xmlns="http://www.w3.org/2005/Atom">
		<author>
			<name type="html" xml:space="preserve"><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=71">bitsnpcs</a>]]></name>
		</author>
		<published>2021-03-30T01:29:16Z</published>
		<updated>2021-03-31T04:27:18Z</updated>
		<link rel="alternate" type="text/html" href="https://www.linuxliteos.com/forums/showthread.php?tid=7706" />
		<id>https://www.linuxliteos.com/forums/showthread.php?tid=7706</id>
		<title xml:space="preserve"><![CDATA[Free Book - Create Graphical User interfaces with Python]]></title>
		<content type="html" xml:space="preserve" xml:base="https://www.linuxliteos.com/forums/showthread.php?tid=7706"><![CDATA[Hello,<br />
a total beginner to Python can make apps with this book.<br />
The book is called "Create Graphical User interfaces with Python" , the digital version is free to download from here (no login or account needed) -<br />
<br />
<a href="https://magpi.raspberrypi.org/books" target="_blank" rel="noopener" class="mycode_url">https://magpi.raspberrypi.org/books</a><br />
<br />
It shows step by step tutorials to make things like -<ul class="mycode_list"><li>a Meme Generator App<br />
</li>
<li>a Paint type App.<br />
</li>
<li>several Game apps<br />
</li>
<li>and other apps<br />
</li>
</ul>
It looks like a really good book for making your very first Python apps.<br />
At the end of each tutorial you will have a fully working app you have coded.<br />
It uses guizero, this is a wrapper for tkinter, tkinter is the #1 used gui builder for Python, the book would be a great place to start making apps.<br />
I hope it encourages you to give app making a try in your free time.<br />
]]></content>
		<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
	</entry>
	<entry xmlns="http://www.w3.org/2005/Atom">
		<author>
			<name type="html" xml:space="preserve"><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=71">bitsnpcs</a>]]></name>
		</author>
		<published>2021-03-29T00:05:53Z</published>
		<updated>2021-03-31T09:16:38Z</updated>
		<link rel="alternate" type="text/html" href="https://www.linuxliteos.com/forums/showthread.php?tid=7703" />
		<id>https://www.linuxliteos.com/forums/showthread.php?tid=7703</id>
		<title xml:space="preserve"><![CDATA[LiLi pad]]></title>
		<content type="html" xml:space="preserve" xml:base="https://www.linuxliteos.com/forums/showthread.php?tid=7703"><![CDATA[Showing the window maximized (the default)<br />
<br />
<img src="https://i.ibb.co/nfnG5zp/1.png" loading="lazy"  alt="[Image: 1.png]" class="mycode_img" /><br />
<br />
<br />
Showing what happens when the Open button is used, the up arrow moves up in the tree of your files for navigating them.<br />
<br />
<img src="https://i.ibb.co/Yct7vrc/3.png" loading="lazy"  alt="[Image: 3.png]" class="mycode_img" /><br />
<br />
]]></content>
		<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
	</entry>
	<entry xmlns="http://www.w3.org/2005/Atom">
		<author>
			<name type="html" xml:space="preserve"><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=71">bitsnpcs</a>]]></name>
		</author>
		<published>2019-06-30T05:05:23Z</published>
		<updated>2019-06-30T05:05:23Z</updated>
		<link rel="alternate" type="text/html" href="https://www.linuxliteos.com/forums/showthread.php?tid=6273" />
		<id>https://www.linuxliteos.com/forums/showthread.php?tid=6273</id>
		<title xml:space="preserve"><![CDATA[An intro to C and GUI Programming FREE pdf]]></title>
		<content type="html" xml:space="preserve" xml:base="https://www.linuxliteos.com/forums/showthread.php?tid=6273"><![CDATA[Hello, <br />
<br />
this is a free book as PDF read online or download free, also available to buy in Printed version. <br />
<br />
<a href="https://www.raspberrypi.org/magpi-issues/C_GUI_Programming.pdf" target="_blank" rel="noopener" class="mycode_url">https://www.raspberrypi.org/magpi-issues...amming.pdf</a>]]></content>
		<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
	</entry>
	<entry xmlns="http://www.w3.org/2005/Atom">
		<author>
			<name type="html" xml:space="preserve"><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=2797">teage</a>]]></name>
		</author>
		<published>2019-02-06T09:50:43Z</published>
		<updated>2019-02-06T09:50:43Z</updated>
		<link rel="alternate" type="text/html" href="https://www.linuxliteos.com/forums/showthread.php?tid=5981" />
		<id>https://www.linuxliteos.com/forums/showthread.php?tid=5981</id>
		<title xml:space="preserve"><![CDATA[int(3) and int('3') is there a difference? (python3.5)]]></title>
		<content type="html" xml:space="preserve" xml:base="https://www.linuxliteos.com/forums/showthread.php?tid=5981"><![CDATA[So I'm reading a python3 book and working with int(). I follow the directions everything is fine. They have me typing in the shell int('2') and see the result. I noticed if I type int(2) with no apostrophe i get the same result. So my question is this, is there a difference?]]></content>
		<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
	</entry>
	<entry xmlns="http://www.w3.org/2005/Atom">
		<author>
			<name type="html" xml:space="preserve"><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=968">trinidad</a>]]></name>
		</author>
		<published>2019-01-18T02:24:19Z</published>
		<updated>2019-01-18T02:24:19Z</updated>
		<link rel="alternate" type="text/html" href="https://www.linuxliteos.com/forums/showthread.php?tid=5935" />
		<id>https://www.linuxliteos.com/forums/showthread.php?tid=5935</id>
		<title xml:space="preserve"><![CDATA[missing ruby & json file type icons]]></title>
		<content type="html" xml:space="preserve" xml:base="https://www.linuxliteos.com/forums/showthread.php?tid=5935"><![CDATA[My Ruby icons are not showing up in file manager. They show up in the mime type editor, but not in Thunar on the desktop like they should. Json doesn't show up right either. The icons are in the set and show in the mime type editor but not on the desktop. What did I miss?<br />
TC<br />
 ]]></content>
		<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
	</entry>
	<entry xmlns="http://www.w3.org/2005/Atom">
		<author>
			<name type="html" xml:space="preserve"><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=71">bitsnpcs</a>]]></name>
		</author>
		<published>2018-10-31T07:49:13Z</published>
		<updated>2018-10-31T07:49:13Z</updated>
		<link rel="alternate" type="text/html" href="https://www.linuxliteos.com/forums/showthread.php?tid=5739" />
		<id>https://www.linuxliteos.com/forums/showthread.php?tid=5739</id>
		<title xml:space="preserve"><![CDATA[Python special editions vol 1-12 - full circle]]></title>
		<content type="html" xml:space="preserve" xml:base="https://www.linuxliteos.com/forums/showthread.php?tid=5739"><![CDATA[Hello,<br />
<br />
here is the link to the Free download page for (all) volumes 1-12 of the Python Special Editions by Full Circle magazine.<br />
<br />
<a href="https://fullcirclemagazine.org/python-special-editions/" target="_blank" rel="noopener" class="mycode_url">https://fullcirclemagazine.org/python-special-editions/</a><br />
]]></content>
		<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
	</entry>
	<entry xmlns="http://www.w3.org/2005/Atom">
		<author>
			<name type="html" xml:space="preserve"><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=1689">Vera</a>]]></name>
		</author>
		<published>2018-08-03T06:08:36Z</published>
		<updated>2018-08-03T06:08:36Z</updated>
		<link rel="alternate" type="text/html" href="https://www.linuxliteos.com/forums/showthread.php?tid=5510" />
		<id>https://www.linuxliteos.com/forums/showthread.php?tid=5510</id>
		<title xml:space="preserve"><![CDATA[Is anyone using LISP on LL?]]></title>
		<content type="html" xml:space="preserve" xml:base="https://www.linuxliteos.com/forums/showthread.php?tid=5510"><![CDATA[Is anyone using LISP on LL?]]></content>
		<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
	</entry>
	<entry xmlns="http://www.w3.org/2005/Atom">
		<author>
			<name type="html" xml:space="preserve"><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=1590">colin</a>]]></name>
		</author>
		<published>2018-07-13T17:50:59Z</published>
		<updated>2018-07-13T17:50:59Z</updated>
		<link rel="alternate" type="text/html" href="https://www.linuxliteos.com/forums/showthread.php?tid=5473" />
		<id>https://www.linuxliteos.com/forums/showthread.php?tid=5473</id>
		<title xml:space="preserve"><![CDATA[Stuck again, what's wrong?]]></title>
		<content type="html" xml:space="preserve" xml:base="https://www.linuxliteos.com/forums/showthread.php?tid=5473"><![CDATA[I'm trying to learn Python3 from the book Learn Python 3 the Hard Way and find it hard going especially when the code keeps on displaying an error. Take for instance, exercise 20.<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code># ex20: Functions and Files    <br />
 &nbsp;&nbsp;from sys import argv    <br />
 &nbsp;&nbsp;script, input_file = argv    <br />
 &nbsp;&nbsp;def print_all(f):     &nbsp;&nbsp;print(f.read())    <br />
 &nbsp;&nbsp;def rewind(f):     &nbsp;&nbsp;f.seek(0) &nbsp;&nbsp;<br />
def print_a_line(line_count, f):     &nbsp;&nbsp;print(line_count, f.readline())    <br />
 &nbsp;&nbsp;current_file = open(input_file)    <br />
 &nbsp;&nbsp;print("First let's print the whole file:&#92;n")    <br />
 &nbsp;&nbsp;print_all(current_file)    <br />
 &nbsp;&nbsp;print("Now let's rewind, kind of like a tape.")    <br />
 &nbsp;&nbsp;rewind(current_file)    <br />
 &nbsp;&nbsp;print("Let's print three lines:")    <br />
 &nbsp;&nbsp;current_line = 1 &nbsp;&nbsp;print_a_line(current_line, current_file)    <br />
 &nbsp;&nbsp;current_line = current_line + 1 &nbsp;&nbsp;print_a_line(current_line, current_file)    <br />
 &nbsp;&nbsp;current_line = current_line + 1 &nbsp;&nbsp;print_a_line(current_line, current_file)</code></div></div>I keep getting the following error<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>colin@my_new_LinuxLite4.0:~&#36; python3 ~/python_exp/ex20.pyTraceback (most recent call last):    File "/home/colin/python_exp/ex20.py", line 7, in &#x26;tmodule&#x26;t     &nbsp;&nbsp;script, input_file = argvValueError: not enough vales to unpack (expected 2, got 1)colin@my_new_LinuxLite4.0:~&#36;</code></div></div>I've come across this error on a previous exercise but sadly misplaced my notes on how to remedy the error. Can someone help me please.  <br />
]]></content>
		<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
	</entry>
	<entry xmlns="http://www.w3.org/2005/Atom">
		<author>
			<name type="html" xml:space="preserve"><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=1590">colin</a>]]></name>
		</author>
		<published>2018-07-10T21:21:01Z</published>
		<updated>2018-07-10T21:21:01Z</updated>
		<link rel="alternate" type="text/html" href="https://www.linuxliteos.com/forums/showthread.php?tid=5464" />
		<id>https://www.linuxliteos.com/forums/showthread.php?tid=5464</id>
		<title xml:space="preserve"><![CDATA[displaying a monthly calendar]]></title>
		<content type="html" xml:space="preserve" xml:base="https://www.linuxliteos.com/forums/showthread.php?tid=5464"><![CDATA[I came across a Python 3 tutorial for displaying a monthly calendar and it worked a treat from the command-line but for some reason it would not work after i added the Python shebang <div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#!/usr/bin/env python 3.6.</code></div></div>Instead it would produce a load of errors. Have since been informed that i had to change the file name from calendar.py to my_calendar.py and once again it worked a treat.<br />
Still cannot work it out why the program didn't work because 'calendar' is not a reserved word?  ]]></content>
		<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
	</entry>
	<entry xmlns="http://www.w3.org/2005/Atom">
		<author>
			<name type="html" xml:space="preserve"><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=71">bitsnpcs</a>]]></name>
		</author>
		<published>2018-05-18T22:49:40Z</published>
		<updated>2018-05-18T22:50:18Z</updated>
		<link rel="alternate" type="text/html" href="https://www.linuxliteos.com/forums/showthread.php?tid=5260" />
		<id>https://www.linuxliteos.com/forums/showthread.php?tid=5260</id>
		<title xml:space="preserve"><![CDATA[Project - UK Thunderball killa / Open Source donation Builder]]></title>
		<content type="html" xml:space="preserve" xml:base="https://www.linuxliteos.com/forums/showthread.php?tid=5260"><![CDATA[Hello,<br />
<br />
adjusted Lotto killas so it works for the UK Thunderball draw.<br />
<br />
 <img src="https://preview.ibb.co/mfodty/thunder.png" loading="lazy"  alt="[Image: thunder.png]" class="mycode_img" /><br />
<br />
Screenshot of Thunderball number maker running on Linux Lite in terminal and its code in Gedit.<br />
This will pick your 5 number choices from the 39, and then pick your 1 Thunderball number from the 14 numbers.<br />
It will also give you real life choices to make (interactive)<br />
<br />
Here is the code -<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>from random import *<br />
 <br />
thunderchoices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]<br />
<br />
thunderball = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]<br />
 <br />
# Picks 5 numbers from the choices <br />
x = sample(thunderchoices, 5)<br />
<br />
# Picks your thunderball<br />
y = sample(thunderball, 1) &nbsp;&nbsp;<br />
<br />
print x <br />
print y<br />
<br />
print ("You have Options - " "&#92;nDonate a percentage of any wins to your favorite project" "&#92;nDonate the stake instead to your favorite project")</code></div></div><br />
Copy/paste in to Leafpad document in Home folder and save as thunder.py<br />
<br />
<br />
Hold down Ctrl and Alt then press t (Ctrl+Alt+t)<br />
Copy/paste or type into terminal -<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>python thunder.py</code></div></div><br />
Hope you enjoy reading this.]]></content>
		<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
	</entry>
	<entry xmlns="http://www.w3.org/2005/Atom">
		<author>
			<name type="html" xml:space="preserve"><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=71">bitsnpcs</a>]]></name>
		</author>
		<published>2018-05-18T20:38:06Z</published>
		<updated>2018-05-23T17:33:11Z</updated>
		<link rel="alternate" type="text/html" href="https://www.linuxliteos.com/forums/showthread.php?tid=5259" />
		<id>https://www.linuxliteos.com/forums/showthread.php?tid=5259</id>
		<title xml:space="preserve"><![CDATA[Project - UK & EU Lottery killas / Open Source donation builders]]></title>
		<content type="html" xml:space="preserve" xml:base="https://www.linuxliteos.com/forums/showthread.php?tid=5259"><![CDATA[removed friendliness, it is off topic here Admin says.<br />
<br />
<br />
<br />
<br />
<img src="https://preview.ibb.co/hfQrfd/lot.png" loading="lazy"  alt="[Image: lot.png]" class="mycode_img" /><br />
<br />
UK lottery random number picker, showing the Python code, and the successful running of this in Linux Lite Terminal.<br />
<br />
Here is the code -<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>from random import *<br />
 lottochoices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]<br />
<br />
# Picks 6 lotto numbers from the choices <br />
x = sample(lottochoices, 6)<br />
print x <br />
<br />
print ("You have Options - " "&#92;nDonate a percentage of any wins to your favorite project" "&#92;nDonate the stake instead to your favorite project")</code></div></div><br />
Copy/paste this into a leafpad file in your Home Directory and name this file <span style="font-weight: bold;" class="mycode_b">lot.py</span><br />
<br />
To run the file do -<br />
Hold down Ctrl + Alt and press t (Ctrl+Alt+t)<br />
Copy/paste or type in to your terminal <br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>python lot.py</code></div></div><br />
The output will be of the form shown in the above screenshot, that is 6 numbers randomly picked from the 59 as you would do on a lottery ticket in UK.<br />
Then choose your options in real life (interactive)<br />
<br />
<br />
EU Lottery picker  -<br />
<br />
<img src="https://preview.ibb.co/bRo2Ld/eulot.png" loading="lazy"  alt="[Image: eulot.png]" class="mycode_img" /><br />
<br />
EU lottery screenshot, showing Python code and the successful running of this in Linux Lite terminal.<br />
This will pick from the 50 numbers your 5 numbers.<br />
It will also pick from the 12 numbers your 2 lucky star numbers.<br />
It will also output text with lifestyle options (interactivity)<br />
<br />
Here is the code - <div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>from random import *<br />
 <br />
euchoices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]<br />
<br />
luckystars = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]<br />
 <br />
# Picks 5 lotto numbers from the choices <br />
x = sample(euchoices, 5)<br />
<br />
# Picks your lucky stars<br />
y = sample(luckystars, 2) &nbsp;&nbsp;<br />
<br />
print x <br />
print y<br />
<br />
print ("You have Options - " "&#92;nDonate a percentage of any wins to your favorite project" "&#92;nDonate the stake instead to your favorite project")</code></div></div><br />
Copy/paste this into a leafpad file in your Home Directory and name this file <span style="font-weight: bold;" class="mycode_b">eulot.py</span><br />
<br />
To run the file do -<br />
Hold down Ctrl + Alt and press t (Ctrl+Alt+t)<br />
Copy/paste or type in to your terminal <br />
<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>python eulot.py</code></div></div><br />
I hope it was interesting to read.]]></content>
		<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
	</entry>
	<entry xmlns="http://www.w3.org/2005/Atom">
		<author>
			<name type="html" xml:space="preserve"><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=2135">alowe</a>]]></name>
		</author>
		<published>2018-04-03T01:31:17Z</published>
		<updated>2018-04-03T02:06:00Z</updated>
		<link rel="alternate" type="text/html" href="https://www.linuxliteos.com/forums/showthread.php?tid=5142" />
		<id>https://www.linuxliteos.com/forums/showthread.php?tid=5142</id>
		<title xml:space="preserve"><![CDATA[Using Linux has inspired me to learn C and here's my MORSE program]]></title>
		<content type="html" xml:space="preserve" xml:base="https://www.linuxliteos.com/forums/showthread.php?tid=5142"><![CDATA[Something about using Linux encourages me to learn C. So I wrote a simple program to output morse code.<br />
<br />
I wanted it to play the morse a bit faster but if I reduce the sample lengths any further they fail to play at all. So this looks like it's as far as it will go. Never intended for it to be practical. Just wanted to try something.<br />
<br />
I'm not sure if attaching Linux executables is safe or advisable (it isn't on Windows systems). Incase it doesn't work or you want to compile it yourself, here is the code:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>// Compilation:<br />
//  gcc -o morse morse.c -lao -ldl -lm<br />
<br />
#include &#x26;tstdio.h&#x26;t<br />
#include &#x26;tunistd.h&#x26;t<br />
#include &#x26;tstring.h&#x26;t<br />
#include &#x26;tao/ao.h&#x26;t<br />
#include &#x26;tmath.h&#x26;t<br />
<br />
#define bool char<br />
#define true 1<br />
#define false 0<br />
<br />
#define dot 25200&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// length of dot sound<br />
#define dash 44100&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// length of dash sound<br />
#define delay 200000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// delay in microseconds between dots and dashes in morse code<br />
<br />
const char* morse[] = {<br />
&nbsp;&nbsp;&nbsp;&nbsp;".-",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// A<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-...", &nbsp;&nbsp;&nbsp;&nbsp;// B<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-.-.",&nbsp;&nbsp;&nbsp;&nbsp;// C<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-..",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// D<br />
&nbsp;&nbsp;&nbsp;&nbsp;".",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// E<br />
&nbsp;&nbsp;&nbsp;&nbsp;"..-.",&nbsp;&nbsp;&nbsp;&nbsp;// F<br />
&nbsp;&nbsp;&nbsp;&nbsp;"--.",&nbsp;&nbsp;&nbsp;&nbsp;// G<br />
&nbsp;&nbsp;&nbsp;&nbsp;"....",&nbsp;&nbsp;&nbsp;&nbsp;// H<br />
&nbsp;&nbsp;&nbsp;&nbsp;"..",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// I<br />
&nbsp;&nbsp;&nbsp;&nbsp;".---",&nbsp;&nbsp;&nbsp;&nbsp;// J<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-.-",&nbsp;&nbsp;&nbsp;&nbsp;// K<br />
&nbsp;&nbsp;&nbsp;&nbsp;".-..",&nbsp;&nbsp;&nbsp;&nbsp;// L<br />
&nbsp;&nbsp;&nbsp;&nbsp;"--",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// M<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-.",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// N<br />
&nbsp;&nbsp;&nbsp;&nbsp;"---",&nbsp;&nbsp;&nbsp;&nbsp;// O<br />
&nbsp;&nbsp;&nbsp;&nbsp;".--.",&nbsp;&nbsp;&nbsp;&nbsp;// P<br />
&nbsp;&nbsp;&nbsp;&nbsp;"--.-",&nbsp;&nbsp;&nbsp;&nbsp;// Q<br />
&nbsp;&nbsp;&nbsp;&nbsp;".-.",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// R<br />
&nbsp;&nbsp;&nbsp;&nbsp;"...",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// S<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// T<br />
&nbsp;&nbsp;&nbsp;&nbsp;"..-",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// U<br />
&nbsp;&nbsp;&nbsp;&nbsp;"...-",&nbsp;&nbsp;&nbsp;&nbsp;// V<br />
&nbsp;&nbsp;&nbsp;&nbsp;".--",&nbsp;&nbsp;&nbsp;&nbsp;// W<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-..-",&nbsp;&nbsp;&nbsp;&nbsp;// X<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-.--",&nbsp;&nbsp;&nbsp;&nbsp;// Y<br />
&nbsp;&nbsp;&nbsp;&nbsp;"--..",&nbsp;&nbsp;&nbsp;&nbsp;// Z<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-----",&nbsp;&nbsp;&nbsp;&nbsp;// 0<br />
&nbsp;&nbsp;&nbsp;&nbsp;".----",&nbsp;&nbsp;&nbsp;&nbsp;// 1<br />
&nbsp;&nbsp;&nbsp;&nbsp;"..---",&nbsp;&nbsp;&nbsp;&nbsp;// 2<br />
&nbsp;&nbsp;&nbsp;&nbsp;"...--",&nbsp;&nbsp;&nbsp;&nbsp;// 3<br />
&nbsp;&nbsp;&nbsp;&nbsp;"....-",&nbsp;&nbsp;&nbsp;&nbsp;// 4<br />
&nbsp;&nbsp;&nbsp;&nbsp;".....",&nbsp;&nbsp;&nbsp;&nbsp;// 5<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-....",&nbsp;&nbsp;&nbsp;&nbsp;// 6<br />
&nbsp;&nbsp;&nbsp;&nbsp;"--...",&nbsp;&nbsp;&nbsp;&nbsp;// 7<br />
&nbsp;&nbsp;&nbsp;&nbsp;"---..",&nbsp;&nbsp;&nbsp;&nbsp;// 8<br />
&nbsp;&nbsp;&nbsp;&nbsp;"----."&nbsp;&nbsp;&nbsp;&nbsp;// 9<br />
};<br />
<br />
void dotdash(char* code, ao_device* device, char* buffer, char audio, char reveal, char suppress)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;// exit early if there's nothing to do<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (!audio &amp;&amp; suppress) return;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// play dot and dash sounds for each dot and dash in code<br />
&nbsp;&nbsp;&nbsp;&nbsp;for (int i=0; i &#x26;t strlen(code); i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (audio) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch (code[i]) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case '.': ao_play(device, buffer, dot); break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case '-': ao_play(device, buffer, dash); break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// ignore other characters<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (reveal &amp;&amp; !suppress) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("%c", code[i]);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fflush(stdout);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;usleep(delay);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (reveal &amp;&amp; !suppress) printf(" ");<br />
&nbsp;&nbsp;&nbsp;&nbsp;usleep(delay);<br />
}<br />
<br />
int main(int argc, char** argv)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;ao_device* device;<br />
&nbsp;&nbsp;&nbsp;&nbsp;ao_sample_format format;<br />
&nbsp;&nbsp;&nbsp;&nbsp;char* buffer;<br />
&nbsp;&nbsp;&nbsp;&nbsp;float freq = 1000.0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// the pitch of the sound<br />
&nbsp;&nbsp;&nbsp;&nbsp;int default_driver, buf_size, sample, i;<br />
&nbsp;&nbsp;&nbsp;&nbsp;char ascii, opt, optcount=0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;bool audio=false, reveal=false, suppress=false;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// read options<br />
&nbsp;&nbsp;&nbsp;&nbsp;for (i=1; i&#x26;targc; i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (argv[i][0] == '-' &amp;&amp; strlen(argv[i]) &#x26;t 1) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;opt = (argv[i][1] &#x26;t= 65 &amp;&amp; argv[i][1] &#x26;t= 90) ? argv[i][1] + 32 : argv[i][1];&nbsp;&nbsp;&nbsp;&nbsp;// convert to lower case<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch (opt) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 'a': audio = true; optcount++; break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 'r': reveal = true; optcount++; break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 's': suppress=true; optcount++; break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// ignore all unrecognised options<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;// the final argument is assumed to be the text to be translated<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// initialise default audio driver<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (audio) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ao_initialize();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default_driver = ao_default_driver_id();<br />
&nbsp;&nbsp;&nbsp;&nbsp;        memset(&amp;format, 0, sizeof(format));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.bits = 16;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.channels = 2;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.rate = 44100;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.byte_format = AO_FMT_LITTLE;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// open audio driver<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;device = ao_open_live(default_driver, &amp;format, NULL);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (device == NULL) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!suppress) printf("Error opening audio device.&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr, "Error opening audio device.&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else {&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// create morse sound<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buf_size = format.bits/8 * format.channels * format.rate;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer = calloc(buf_size, sizeof(char));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (i = 0; i &#x26;t format.rate; i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sample = (int)(0.75 * 32768.0 * sin(2 * M_PI * freq * ((float) i/format.rate)));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// left and right channel<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer[4*i] = buffer[4*i+2] = sample &amp; 0xff;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer[4*i+1] = buffer[4*i+3] = (sample &#x26;t&#x26;t 8) &amp; 0xff;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// disable audio and reveal options if audio failed to initialise<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (device == NULL) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;audio = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reveal = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// usage<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (argc == 1) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("Usage: morse [opt] [text]&#92;n&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(" -a&nbsp;&nbsp;&nbsp;&nbsp;output audio (requires libao): sudo apt-get install libao-dev&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(" -r&nbsp;&nbsp;&nbsp;&nbsp;reveal morse as audio is played&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(" -s&nbsp;&nbsp;&nbsp;&nbsp;suppress text output&#92;n&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("Translates to international morse code. Put text in quotes if including spaces.&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("Only alphanumeric characters translated. All other characters are ignored.&#92;n");<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// output text translation<br />
&nbsp;&nbsp;&nbsp;&nbsp;} else if (argc &#x26;t optcount + 1) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// regardless of audio, if there is no reveal just print the morse quickly<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!reveal &amp;&amp; !suppress) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (i=0; i &#x26;t strlen(argv[argc-1]); i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ascii = argv[argc-1][i];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (ascii == 32) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// spaces<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(" ");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else if (ascii &#x26;t= 48 &amp;&amp; ascii &#x26;t= 57) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// numbers 0 to 9...<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("%s", morse[ascii-48+26]);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else if ( (ascii &#x26;t= 65 &amp;&amp; ascii &#x26;t= 90) || (ascii &#x26;t=97 &amp;&amp; ascii &#x26;t= 122) ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// letters a to z...<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( ascii &#x26;t= 97 ) ascii -= 32;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("%s", morse[ascii-65]);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (ascii != 32 ) printf(" ");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fflush(stdout);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// but if there is audio or the morse is being revealed in morse timing then step though it<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (audio || reveal) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (i=0; i &#x26;t strlen(argv[argc-1]); i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ascii = argv[argc-1][i];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (ascii == 32) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// spaces<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!suppress) printf(" ");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;usleep(delay*2);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else if (ascii &#x26;t= 48 &amp;&amp; ascii &#x26;t= 57) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// numbers 0 to 9...<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dotdash((char*) morse[ascii-48+26], device, buffer, audio, reveal, suppress);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else if ( (ascii &#x26;t= 65 &amp;&amp; ascii &#x26;t= 90) || (ascii &#x26;t=97 &amp;&amp; ascii &#x26;t= 122) ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// letters a to z...<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( ascii &#x26;t= 97 ) ascii -= 32;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dotdash((char*) morse[ascii-65], device, buffer, audio, reveal, suppress);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!suppress) printf("&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// close and shutdown<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (audio) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ao_close(device);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ao_shutdown();<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;return (device == NULL) ? 0 : 1;<br />
}</code></div></div><br />
I can see things that could be improved but resisting the urge to tinker further. E.g. reveal should still work even if the audio driver fails to load and the final return doesn't need a ternary operator. Must resist urge to tinker...<br />
<br />
Expected output:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>Usage: morse [opt] [text]<br />
<br />
 -a&nbsp;&nbsp;&nbsp;&nbsp;output audio (requires libao): sudo apt-get install libao-dev<br />
 -r&nbsp;&nbsp;&nbsp;&nbsp;reveal morse as audio is played<br />
 -s&nbsp;&nbsp;&nbsp;&nbsp;suppress text output<br />
<br />
Translates to international morse code. Put text in quotes if including spaces.<br />
Only alphanumeric characters translated. All other characters are ignored.</code></div></div><br />
Any number of options can be given in any order. If using audio, the morse is played slowly enough that you can learn how to recognise the sounds. If you wanted to use it to play fast morse I guess you could sample the raw output into something like Audacity and then speed it up without raising the pitch. If your device doesn't support direct sampling internally then just use a male to male audio jack between the microphone and headphone inputs. Does the job.<br />
<br />
<span style="font-weight: bold;" class="mycode_b">Edit:</span><br />
Have attached an example.mp3 file to show what that the following message sounds like when sped up in Audacity:<br />
"Example of output from the morse program"<br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.linuxliteos.com/forums/images/attachtypes/zip.png" title="ZIP File" border="0" alt=".zip" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=74" target="_blank" title="">morse.zip</a> (Size: 4.59 KB / Downloads: 349)
<!-- end: postbit_attachments_attachment --><br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.linuxliteos.com/forums/images/attachtypes/zip.png" title="ZIP File" border="0" alt=".zip" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=75" target="_blank" title="">example.zip</a> (Size: 99.3 KB / Downloads: 362)
<!-- end: postbit_attachments_attachment -->]]></content>
		<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
	</entry>
</feed>