Skip to main content

Posts

Showing posts from October, 2020

Dynamic Facebook Share Button for Your website and web pages | No configuration is required !!

Dynamic Facebook Share Button for Your website and web pages | No configuration is required! 😮😮😮😮 I was wondering how to let people share my webpage through Facebook. Even though Facebook Developer Tools let you create a Facebook button with ease you have to go to the developer's page and paste your URL into a box generate code, copy it, and paste wherever you want. but it is not the problem, The real problem is you have to repeat this process whenever you write a new blogpost/ post for your website. Then you have to use this javascript code for your webpage. It gets your web pages' address with javascript code  document . location . href ;   and passes it to the Facebook share gadget. here is the code and let the hack begin!! < div   id = "fb-root" ></ div > < script > ( function ( d ,  s ,  id ) { var   js ,  fjs  =  d . getElementsByTagName ( s )[ 0 ]; if  ( d . getElementById ( id ))  return ; js  =  d . createElement ( s );  js . id  = 

Get Unlimited Traffic to your website with Python | Make your fun a traffic to your site.

GET UNLIMITED TRAFFIC To your WEBSITE/ BLOG/ Youtube Channel with Python. Getting unlimited traffic is very simple with python. But this is not real traffic because the only visitor is just you. You cannot turn this traffic into money but you can have really fun stuff with your programming skills. JUST follow these simple steps. STEP 1 import webbrowser import webbrowser module to get started. Here the webbrowser driver is built-in so that you have not to install it using PIP STEP 2 install pynput module using PIP if you don't know how to set up pip on your computer this article is just for you.  PIP open cmd or terminal and type this command kavindu@kavindu-MS : ~ $ pip3 install pynput Here I use Ubuntu and I have to type pip3 and if you are a windows user you have to type it as pip write this code  import webbrowser import time from pynput.keyboard import Controller my_url = "https://blogofchamodh.blogspot.com/" keyboard =Controller() def refresh_tab (): key

Display web traffic by location with an Earth on your website | Without coding in 3 minutes

  Add a world map that shows your visitors' countries without coding in 3 minutes. Do you want to show your web traffic by location on your website? and you don't have time or knowledge to code. Then this article is born for you!!!  Just follow the four steps to make your site stunning 👇 Step 1 go to the site :   https://clustrmaps.com/add Step 2 type your websites address in the text box and hit NEXT button. and select the Globe Widget Step 3 You will be redirected to a site with a code  Last Step Copy the code shown inside the textbox and paste it wherever you want to show that globe inside your websites' source code You can also view the analytics of your site for free by visiting:  https://clustrmaps.com/profile/

Updated version of mass telephone number generator. | Short and sweet code.

  https://blogofchamodh.blogspot.com/2020/10/generate-all-possible-phone-numbers.html Here was the first version of the python script that generates crores of telephone numbers. But that script is complex and here is a simple version of the script. Changes to the product() Function. I wanted to generate all possible combinations of seven characters and put 7 lists as parameters of the product function but we can do it with only one list instead of seven lists. But you have to set the value 7 for the parameter "repeat" to tell the function you want a combination of seven characters  product_a = product([ '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , '0' ], repeat = 7 )   And also you can change the product function as follows. product_a = product( '1234567890' , repeat = 7 ) The above line of code does the same job but shortens our code too You have another way to do this thing impo

Generate all possible phone numbers with Python | Generates Crores of Phone Numbers within minutes.

Recently,  I learned about itertools in python. Especially, about the functions permutations, combinations, and products and I tried to make a script that generates all phone numbers in our country. I bet your phone number is too on the list. let the hack begin!!! First, you need to install itertools in your computer  Simply open your terminal and type                sudo apt-get  install  -y python-more- itertools Then Write the code below from itertools import product file_name = "phonebook.txt" phonebook = open (file_name, 'a' ) prefixes = [ '+9471' ] product_a = product([ '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , '0' ], [ '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , '0' ], [ '1' , '2' , '3' , '4' , '5

Single Line White-space remover with Python | Remove all white-spaces of a string with a single line of Python

 What is white-space ? Simply a white-space is a character that contains a space. when you hit your space bar on your keyboard it doesn't leave it empty but it add a Character that contains a single white- space. Removing all white spaces in a  string In Python we have too many ways to do that. Believe me  A For Loop is the easiest way for a beginner. But today I use only one line of code to do the job. Let's get started. Objectives When we have the input "Hello World!" It must return us the string "HelloWorld!" Code print ( "" .join( input ( "Enter the String :" ).split()))                                                   Here we get a input using Input() Then  we split it into words using Split() Split()  Returns us a List We join each and every element using join() if you want to get items in a list joined together you can use join()  You have to decide the connecting string before using Join() and it must be a string. Here we want n

Install PIP3 (Python package installer) on Ubuntu in 10 Seconds

Open Your terminal You can open your terminal by hitting CTRL+ALT+T at once or searching apps for terminal Write the right command... command is : $ sudo apt install python3-pip Type The password for Super User Your password will be hidden so that you cannot see it. Don't worry, Type it Correctly and hit ENTER  [sudo] password for : Accept to Install Enter Y when you asked for the permissions Confirm whether it is installed correctly Your installation is finished and type: ~$ pip3 --version If it outputs the path where it is installed You're all set and ready to install packages using pip. Otherwise you have to repeat above steps correctly. Happy Coding...

Create a simple Digital Clock for Your website with Javascript.

Create a Unordered list in HTML You have to create a unordered list using <ul> and</ul> tags in your HTML file. And inside it include 3 <li> elements for Hours, Minutes and Seconds . ul > < li id = 'hours' ></ li > < li id = 'minutes' ></ li > < li id = 'seconds' ></ li > </ ul > Write The Script With Javascript Then you can place your script inside head tags. < script > function newfunc () { a = new Date (); day = "AM" hours = a . getHours (); if ( hours > 12 ){ hours = hours - 12 ; day = 'PM' } else { } document . getElementById ( "hours" ). innerHTML = ( "0" + hours ). slice (- 2 )+ ':' ; document . getElementById ( "minutes" ). innerHTML = ( "0" + a . getMinutes ()). sli

Unblock Vimeo Domain Block.🔑

 If you have a pro plan for your vimeo account, you can show your videos only for a specified domains. For an example, you have a website https://abc.com and you want to show your vimeo videos only in abc.com Otherwise you want to block someone outside from your website watching your vimeo videos. This is not to teach you how to do  that but I will show you how to unblock the blocked content which is blocked using the above concept. IF YOU DO NOT HAVE THE URL TO THE VIDEO; you can easily find the url of the video following these steps navigate to a page that may have the link right click on the page and select VIEW PAGE SOURCE then the source code will appear in new tab and press CTRL + F to find the url we want then type VIMEO in the new search bar and then browser will find the url for us You have to copy it LET THE HACK BEGIN open your terminal (In Windows : Command Prompt ) and type the command below           curl --referrer [allowed_domain] -o [file_name] [url_of_the_video] The

Version 1.1 of RESULTANT FINDER is released!

A few weeks before I released my first version of Resultant finder which helps you to calculate the resultant of two vectors using a formula. When I wanted to find the resultant of a big number of vectors I built software with a different logic to find the size and its direction. In this version: the software divides the vector into two components along the y-axis and x-axis and lists them into two lists. after the user finished entering inputs; Python calculates the sum of all x components and y components and  calculate the results of all vectors given with the support of the Pythagoras Theorem and Triangle of vectors. As the vector triangle is right angled we can simply calculate the tan ratio of the angle, between the resultant and x-axis t hat is all here is the code: https://github.com/ChamodhNethsara/resultant/blob/main/resultant.py Hope You Like it :-) Happy coding Kavindu Chamodh Nethsara   

Count views of a page in django with python.

 Hello Guys I am sure that you are interested in Django. Today we are going to add a view count to our page( Here I add the view counter for a post in my blogging app) You can add it to anything you want to follow me, guys... First, open Your model.py select the object here I choose the Post class and add an integer field to your class and set its default value to by typing these simple lines     view_count = models.IntegerField(default=0) and in the views.py navigate to the view function that shows the post in your app and add the lines below     def view_post(request,post_id):          post = Post.objects.get(pk=post_id)          post.view_count += 1          post.save() after that, you have to send the context to our template by extending the view_function with these lines of python     --snip--     return render(request,'YOUR_TEMPLATE'S_PATH',{'view_count':view_count} go to your template which shows the post and add a line to show the view count as you wish. he

Find the Resultant vector of two Vectors With PYTHON!!

NEW ARTICLE:  How to Find the resultant of multiple vectors with Python! Using Python We can do many complex calculations. I learned how to calculate Resultant Vector using a formula with its size and direction in my Physics class. Then, I simply developed a CLI software to calculate the resultant of given two vectors Hope you like it :>) Follow me... Step :1 You need to install python on your computer. No matter what the operating system is you can find the ideal version of python from the official website of Python org And you will need a code editor like VS code and can download it with a simple Google search. (Hope you hate the first step Haha ) Step 2: we use the math module to calculate our resultant vector. The method I used as follows math.radians() : converts degrees to radians math.degrees() : converts radians to degrees math.sqrt()  : find the square root of a number math.atan() :find the tan inverse Step 3: the formula I used to calculate the size of the resultant is as