Monday 26 December 2022

Step-by-Step Guide to Developing Your First Android App

 Introduction:


Have you always wanted to develop your own Android app but not sure where to start? Look no further! In this article, we will go over the steps to take in order to develop your first Android app.


Prerequisites:


Before you can start developing an Android app, there are a few things you will need to have in place:


A computer: You will need a computer with a stable internet connection to develop your Android app.

Android Studio: Android Studio is the official Integrated Development Environment (IDE) for Android app development. You can download it for free from the Android Developer website.

Java Development Kit (JDK): Android app development requires the use of the Java programming language. You will need to install the JDK on your computer in order to use Android Studio.

An Android device: While it is not required to have an Android device to develop an app, it is recommended to have one to test your app on. You can also use an emulator in Android Studio to test your app.

Step 1: Design your app


Before you start writing any code, it's important to have a clear idea of what you want your app to do and how it will look. You should create a wireframe or a mockup of your app to visualize the different screens and features.


Step 2: Set up Android Studio


Once you have all the prerequisites in place, you can start setting up Android Studio. This involves installing Android Studio on your computer and setting up a new project.


Step 3: Design the layout of your app


The layout of your app determines how the different screens and elements will be arranged on the screen. You can use Android Studio's Layout Editor to design the layout of your app.


Step 4: Write the code for your app


Now it's time to start writing the code for your app. You will need to use the Java programming language to write the code for your app.


Step 5: Test your app


Before you publish your app, it's important to test it to make sure it is functioning correctly. You can use an emulator in Android Studio to test your app or a physical Android device.


Step 6: Publish your app


Once you have tested your app and it is working correctly, you can publish it to the Google Play Store. You will need to create a developer account and follow the submission guidelines in order to publish your app.


Conclusion:


Developing an Android app can seem intimidating at first, but with some patience and dedication, it is possible to create a functional and user-friendly app. By following these steps, you can turn your app idea into a reality.

Search using PHP & MySQL
I'm going to show you how to create a search engine for your website using PHP and MySQL. Here you will learn how.
PHP GET and POST
PHP connect to DB
SQL communicates
This is only a simple project now if get to understand it you will become to design your own search engine. FYI.... if you want some help find me at www.facebook.com/groups/tekkomunity/.
OK LET GET GO....

1. Go to your PHPMyAdmin and navigate to your database and to your main table examle: 

I want to search for title and artis only i will set my type on the title to varchar and artis to text. as you can see all colum need to set as on the screenshot if not, you will get into some issues.









2. Now that you already set all structure as follows, lets get into some codingsssssss.... Now in your root folder create a php file call index.php and fill in this code
inside body tag 
<form action="search.php" method="GET">  <input type="text" name="query" />
<input type="submit" value="Search" />
</form>
Action="search.php"  is pointing to your php that communicate to your SQL database which will do. Method="GET" you tring to infomations not POST.
and we will need input type is text that allow user to fill in some text and the name="query" that will pass the text to PHP and we also need a button type="submit" that will submit our text to PHP valu="Search" the name of the button. 

Batch programming to scan for online IPs

Introduction:

Batch programming is a powerful tool for automating tasks and performing actions on multiple files or devices at once. In this article, we will go over how to use batch programming to scan for online IPs on a network.

What is an IP address?

An IP (Internet Protocol) address is a numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication. It serves as an identifier for the device and allows it to communicate with other devices on the network.

There are two types of IP addresses: public and private. Public IP addresses are assigned by Internet Service Providers (ISPs) and are unique to each device. Private IP addresses, on the other hand, are used within a private network and are not visible to the Internet.

Scanning for online IPs:

To scan for online IPs on a network, we can use the "ping" command in batch programming. The "ping" command sends a request to a device to see if it is online and responds with a message if it is.

Here is an example of a batch script that scans for online IPs on a network:


@echo off

:start
echo Scanning for online IPs...

for /l %%i in (1,1,254) do (
  ping -n 1 192.168.1.%%i | find "TTL=" >nul
  if not errorlevel 1 echo 192.168.1.%%i is online
)

echo Scan complete.

pause
goto start


In this script, the "for" loop iterates through all IP addresses from 1 to 254 on the network (192.168.1.1 to 192.168.1.254). The "ping" command is used to send a request to each IP address, and the "find" command is used to check if a response was received. If a response was received, it means the device is online and the IP address is displayed.

This script will continuously scan for online IPs and display them on the screen until it is stopped.

Conclusion:

Batch programming is a useful tool for automating tasks and performing actions on multiple devices at once. In this article, we learned how to use the "ping" command in batch programming to scan for online IPs on a network. By running this script, you can easily see which devices are online and their corresponding IP addresses.

5 Tips for Getting Started with Learning to Code

 Introduction:


Are you interested in learning how to code but not sure where to start? Don't worry, you're not alone! With so many programming languages, online courses, and resources available, it can be overwhelming to know where to begin.


In this article, we will go over five tips to help you get started on your journey to learning how to code.


Choose a programming language:

There are many programming languages to choose from, each with its own unique features and applications. Some popular languages include Python, Java, C++, and JavaScript.


When choosing a programming language, consider what you want to do with it. Do you want to build websites? Then you might want to consider HTML, CSS, and JavaScript. Do you want to work with data? Then Python might be a good choice.


It's also important to consider the job market and the demand for different programming languages. For example, Python and Java are in high demand in the software development field.


Find online resources and courses:

There are many online resources and courses available to help you learn how to code. Some popular ones include Codecademy, Coursera, and Udemy.


Before choosing a course or resource, make sure to do some research and read reviews to find one that is right for you. Consider the cost, duration, and the teaching style of the course.


Practice, practice, practice:

One of the most important things when learning how to code is to practice. The more you practice, the better you will become.


Try to set aside time each day or week to practice coding. This could be working through online exercises or building small projects.


Join a community:

Learning to code can be a solitary activity, but it doesn't have to be. Joining a community of other aspiring coders can be a great way to get support, ask questions, and share your progress.


There are many online communities, such as forums and social media groups, where you can connect with other learners. You can also consider joining a local meetup group or finding a coding buddy to work with.


Don't give up:

Learning to code can be challenging, and it's natural to feel frustrated at times. However, it's important to persevere and not give up.


Remember that everyone starts somewhere and it takes time and practice to become proficient at coding. If you hit a roadblock, try to take a break and come back to it later, or seek help from online resources or a community.


Conclusion:


Learning how to code can be a rewarding and fulfilling experience. By following these tips, you can set yourself up for success and start your journey towards becoming a proficient coder. Remember to choose a programming language, find online resources and courses, practice, join a community, and don't give up. With dedication and perseverance, you can achieve your goals.


Linux for Beginners: A Comprehensive Guide

Introduction:


Are you interested in learning about Linux but not sure where to start? Look no further! This article is a comprehensive guide for beginners looking to get started with Linux.


What is Linux?


Linux is an operating system, just like Windows and MacOS, but it is based on open-source software. This means that anyone can modify and distribute the source code of Linux freely. Linux is known for being stable, secure, and efficient, and it can be used on a wide range of devices, from desktops and laptops to servers and smartphones.


Getting started with Linux:


There are several ways to try out Linux and see if it's right for you. One option is to create a bootable USB drive or burn a Linux installation disc and boot from it. This will allow you to try out Linux without affecting your existing operating system.


Another option is to install Linux alongside your existing operating system, which is known as a dual-boot setup. This allows you to choose which operating system to boot into when you start your computer.


Once you have Linux installed, you will be greeted with a login screen. Enter your username and password to log in and you will be taken to the desktop.


The desktop of a Linux distribution will look different depending on the distribution you are using. Some popular distributions include Ubuntu, Fedora, and Mint.


On the desktop, you will find icons for different programs and applications. You can launch them by clicking on the icons.


To open a terminal, which is a command-line interface for interacting with the operating system, you can either click on the terminal icon or press "Ctrl + Alt + T" on your keyboard.


In the terminal, you can enter commands to perform various tasks, such as navigating the file system, installing and removing software, and managing system processes.


Conclusion:


We hope this article has helped you understand the basics of Linux and how to get started with it. Linux is a powerful and flexible operating system that is worth considering if you are looking for an alternative to Windows or MacOS. If you have any questions or want to learn more, there are many resources available online, including forums and documentation, to help you on your Linux journey. 

Friday 30 June 2017

Learning ChatBot - python

import re
import sqlite3
from collections import Counter
from string import punctuation
from math import sqrt
import random
import socket
import wikipedia

# initialize the connection to the database
connection = sqlite3.connect('brain1.sqlite')
cursor = connection.cursor()

# create the tables needed by the program
create_table_request_list = [
    'CREATE TABLE words(word TEXT UNIQUE)',    
    'CREATE TABLE sentences(sentence TEXT UNIQUE, used INT NOT NULL DEFAULT 0)',    
    'CREATE TABLE associations (word_id INT NOT NULL, sentence_id INT NOT NULL, weight REAL NOT NULL)',]
for create_table_request in create_table_request_list:
    try:
        cursor.execute(create_table_request)
    except:
        pass

def get_id(entityName, text):
    """Retrieve an entity's unique ID from the database, given its associated text.    
    If the row is not already present, it is inserted.    
    The entity can either be a sentence or a word."""    
    tableName = entityName+'s'    
    columnName = entityName
    cursor.execute('SELECT rowid FROM '+tableName+' WHERE '+columnName+' = ?', (text,))
    row = cursor.fetchone()
    if row:
        return row[0]
    else:
        cursor.execute('INSERT INTO '+tableName+' ('+columnName+') VALUES (?)', (text,))
        return cursor.lastrowid


def get_words(text):
    """Retrieve the words present in a given string of text.    
    The return value is a list of tuples where the first member is a lowercase word,    
    and the second member the number of time it is present in the text."""    
    wordsRegexpString = '(?:\w+|['+re.escape(punctuation)+']+)'    
    wordsRegexp = re.compile(wordsRegexpString)
    wordsList = wordsRegexp.findall(text.lower())
    return Counter(wordsList).items()


# incoming and outgoing static 
responseqName = ["what is your name", "who are you", "whats your name"]
aName = ["iam called Jarvis", "my name is Jarvis"]
qGreeting = ["hi", "hi there", "hello", "hi Jarvis", "hello Jarvis"]
aGreeting = ["greetings", "hi", "hi there", "hello"] 
#random picking up from 
hereqCommon1 = ["how are you", "how are you doing"]
aCommon1 = ["Iam doing alright", "Iam fine", "doing great, and you?"]
qCommon2 = ["how was your day", "hows your day"]
aCommon2 = ["it was great", "just fine"]
qOnline = ["look for"]
interEro = ["No internet", "i can't go online", 
"connection is not available", "check internet connection", "check "                                                                                                            "internet "                                                                                                            "first",            "no connection", "sorry internet is not available"
            ]

#internet search 
functionB = random.choice(aGreeting)
while True:
    def online():
        interp = "google.com"        try:
            host = socket.gethostbyname(interp)
            socket.create_connection((host, 80), 2)
            print("I am online now ask me anything\n")
            i = input('> ').strip()
            query = i.lower()
            print("Search...")
            ans = wikipedia.summary(query)
            print("> "+ans)
            row = ans
            r = row[1]
            cursor.execute('UPDATE sentences SET used=used+1 WHERE rowid=?', (row[0],))
            print('online> '+r)
        except ConnectionError:
            print("> "+random.choice(interEro))
            return

    # ask for user input; if blank line, exit the loop
    print(":~# "+B)
    H = input(':~# ').strip()
    if H == "":
        print(":~# sorry can't get it")
        exit()
# fire up internet function    
# if H in qName:    
#     print(":~# "+random.choice(aName))
    # 
#elif H in qGreeting:    
# 
#    
print(":~# "+random.choice(aGreeting))
    # elif H in qCommon1:
    #
     print(":~# "+random.choice(aCommon1))
    # elif H in qCommon2:
    #     
print(":~# "+random.choice(aCommon2))
    #
 #
 elif H == "wiki":
    #
 #
     online()
    # 
else:
    #
     print(":~# "+B)
    #
    #store the association between the bot's message words and the user's response
    words = get_words(B)
    words_length = sum([n * len(word) for word, n in words])
    sentence_id = get_id('sentence', H)
    for word, n in words:
        word_id = get_id('word', word)
        weight = sqrt(n / float(words_length))
        cursor.execute('INSERT INTO associations VALUES (?, ?, ?)', (word_id, sentence_id, weight))
    connection.commit()

    # retrieve the most likely answer from the database
    cursor.execute('CREATE TEMPORARY TABLE results(sentence_id INT, sentence TEXT, weight REAL)')
    words = get_words(H)
    words_length = sum([n * len(word) for word, n in words])
    for word, n in words:
        weight = sqrt(n / float(words_length))
        cursor.execute(
            'INSERT INTO results SELECT associations.sentence_id, 
             sentences.sentence, ?*associations.weight/(4+sentences.used) 
             FROM words INNER JOIN associations ON associations.word_id=words.row id INNER JOIN sentences ON sentences.row id=associations.sentence_id WHERE words.word=?',
            (weight, word,))
    # if matches were found, give the best one
    cursor.execute(
        'SELECT sentence_id, sentence, SUM(weight) AS sum_weight FROM results GROUP BY sentence_id ORDER BY sum_weight DESC LIMIT 1')
    row = cursor.fetchone()
    cursor.execute('DROP TABLE results')
    # otherwise, just randomly pick one of the least used sentences or search on internet
    if row is None:
        cursor.execute(
            'SELECT rowid, sentence FROM sentences WHERE used = (SELECT MIN(used) FROM sentences) ORDER BY RANDOM() LIMIT 1')
        row = cursor.fetchone()
    # tell the database the sentence has been used once more, and prepare the sentence
    B = row[1]
    cursor.execute('UPDATE sentences SET used=used+1 WHERE rowid=?', (row[0],))

Sunday 17 April 2016

Speedtest in Linux Terminal

How to check your download speed from Linux Terminal

Getting to speedtest page will need few thing in order for speedtest to work. You will need google chrome, Mozilla and of course flash player. let say you a working with server terminal or a workstation dosnt meet the requirements.

Open your terminal and issue the following commands

1.First you need apt-get install python-pip
2. pip install speedtest-cli
3. And finally run your speedtest-cli