How to install Marathi Fonts on Windows 10

Installing fonts in microsoft office on windows office is very simple process, follow below mentioned steps.

  • Download required front from internet.

You can download font from any of the following location ( Please check copyrights on below sites, these are shared for reference only. I am not aware of copyright and user licensing at below locations,).

http://www.marathimati.com/downloads/marathi-fonts

http://devanagarifonts.net/marathifonts.html

http://marathi.indiatyping.com/index.php/download-marathi-font

  • Installing fonts

got to Control Panel –> Appearance and Personalization –> Fonts

or simple type fonts in Cortana search box and it will take you to required folder.

To install newly downloaded font, simple drag *.ttf file and it will install the required font.

Installing Marathi font on windows 10
  • Using newly installed fonts

Reopen Microsoft Word and select font type as newly installed font as below.

Selecting Marathi Font Windows 10

After selecting font start typing using English keyboard and word will automatically convert it into required Marathi text.

Please let me know if you run into any issues while following above steps

How to randomly select files from folder using Python

While doing image processing using python, I wanted to select image file randomly from images folder. I found couple of ways of doing this but following is the simplest way to get random file name

 

 
import os
import random

path ='/code/github/python'
files = os.listdir(path)
index = random.randrange(0, len(files))
print(files[index])

 

How to add Drop Caps in WordPress without using any plugins

WordPress has plugins for anything that you need to do. Even if you don’t know any coding, you can create wonderful website, however, adding too many plugins clutter your WordPress website.

Also, having too many plugins can cause slowness in your WordPress website and some plugins can misbehave because of interfernce from some other plugin.

Having dropcaps is very basic requirement and I dont think you need to use plugin for this. You can simply copy past following css in Customize->Additional CSS

div.entry-content p:first-child:first-letter {
float:left;
font-size:2.5em;
color: inherit;
margin-right:0.10em;
line-height:90%;
}

 

How to set up Static Front Page with WordPress

By default, WordPress shows the latest posts, but what if you wanted the homepage of your website to display the same page every time. This “static front page” look is common for users desiring static or welcoming information on the front page of the site.

There are two ways to add Static Front Page

  1. Go to the Pages > Add a New Page dashboard page. This option is on the left sidebar in your WordPress Dashboard.
    Name the page “Home” and type whatever you want for the content your homepage.
  2. Create a template called as front-page.php and add whatever you want to add here. This can be static or dynamic as per your needs.
  3. Add another page called “Blog” and leave the content of the page as blank.
  4. Now go  to the Settings > Reading Settings dashboard page.WordPress Static Page Settings
  5. By default :Your Latest posts is chosen. Select “A Static Page (Choose Below)”.
    For “Front Page”, choose the “Home” page you just created.
    For “Posts Page”, choose the  “Blog” page you created.

That’s all, your static page along with normal log page is created.

Let’s have a look at second approach.

  1. Create a new template in WordPress file directory and name it as home.php . Due to naming convention and prioritization, home.php will be provided priority over index.php. Here is simplest home.php .
    <?php
    /**
    Template Name: Home Page
    */
    get_header(); ?>
    <p>Add any functionality here. This is new blog home p</p>
    <?php
    get_footer();?>

     

  2. Copy index.php into new file called as blogindex.php and add following lines at the top of the file.
    <?php 
    /** 
    Template Name: Blog Index Page 
    */
    ?>

    Here, you would need to add WP_Query as well.

  3. Create a page called as “blog” and assign a template “Blog Index Page” to it. Please not that, in this approach, you don’t have to make any changes in  Settings > Reading

Once above is done, your static home page along with blogs page is ready.

How to add Bootstrap to WordPress Themes

I created child theme using tweentyseventeen, you can follow the steps here. Once I created child theme, I found that I need to create some layouts and to create it, I would have have to write some CSS from scratch.

But when you have amazing tools like bootstrap, why do we need to write css from scratch.

But how to add bootstrap to WordPress theme ?

You can simple add css and js files in head and footer files but that’s not the proper way. You can add bootstrap to your theme by adding following code to functions.php file of your child theme

function my_scripts_enqueue() {

wp_register_script( 'popper-js', 'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js', array('jquery'), NULL, true );
wp_register_script( 'bootstrap-js', 'https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js', array('jquery'), NULL, true );
wp_register_style( 'bootstrap-css', 'https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css', false, NULL, 'all' );

wp_enqueue_script( 'popper-js' );
wp_enqueue_script( 'bootstrap-js' );

wp_enqueue_style( 'bootstrap-css' );
}
add_action( 'wp_enqueue_scripts', 'my_scripts_enqueue' );

Once done you can see bootstrap in your webpage’s source code. You can start using bootstrap class in your template files.

How to Create a WordPress Child Theme

Creating child theme is one of the best options provided by WordPress ecosystem. By using child theme you can utilize features provided by parent theme along with customization that you want to do. And the best part is that, you do not loose any further updates to parent theme.

WordPress theme such as tweenty seventeen, twenty fifteen have been developed and tested by hundreds are developer and it makes no sense to reinvent the wheel. You can simply use the well tested wheel and modify as per your needs.

Please follow below steps for creating child themes

Step#1 Create Basic Structure

A child theme consists of at least one directory (the child theme directory) and two files (style.css and functions.php), which you will need to create:

Create a folder and name it as required. I have created a child theme of ‘twentyseventeen’ so I created folder name ‘twentyseventeen-child’

Step#2 Update style.css

Copy following code in style.css. Please note to change child theme name as required.

/*
Theme Name: twentyseventeen-child-fintrekking
Theme URI: 
Description: twentyseventeen-child-fintrekking
Author: Pravin Jagtap Deshamukh
Author URI: http://example.com
Template: twentyseventeen
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: fintrekking
Text Domain: twentyseventeen-child-fintrekking
*/

The Template line corresponds to the directory name of the parent theme. The parent theme in our example is the Twenty Seventeen theme, so the Template will be twentyseventeen. You may be working with a different theme, so adjust accordingly.

Updating function.php

If you use child theme at this point of time, it will load something like below. This is due to the fact that child theme is not yet importing parent style.css

WordPress Child theme CSS not loaded error

Step#3 Update functions.php

You can import parents style two two methods

  1. Using @import in child themes style.css
  2. Using function.php

Using function.php is recommended method and we will use the same.

<?php
function my_theme_enqueue_styles() {

$parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.

wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get('Version')
);
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>

Note: Please make sure you add correct parent style. Here you need to replace word parent with parent theme name.

e.g.

$parent_style = 'twentyfifteen-style'
$parent_style = 'twentyseventeen-style'

Old way of including style.css is by adding following code in child themes style.css. This is not a recommended method but it works. Add import statement right after template definition as shown below

/*
Theme Name: twentyseventeen-child-fintrekking
Theme URI: 
Description: twentyseventeen-child-fintrekking
Author: Pravin Jagtap Deshamukh
Author URI: http://example.com
Template: twentyseventeen
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: fintrekking
Text Domain: twentyseventeen-child-fintrekking
*/

@import url("../twentyseventeen/style.css");

Once this is updated, you can see the theme CSS is loaded properly.

WordPress Child theme CSS working properly

Step#4 changing other php files

Your child theme can override any file in the parent theme: simply include a file of the same name in the child theme directory, and it will override the equivalent file in the parent theme directory when your site loads. For instance, if you want to change the PHP code for the site header, you can include a header.php in your child theme’s directory, and that file will be used instead of the parent theme’s header.php.

You can also include files in the child theme that are not included in the parent theme. For instance, you might want to create a more specific template than is found in your parent theme, such as a template for a specific page or category archive.

Special case of functions.php

Unlike style.css, the functions.php of a child theme does not override its counterpart from the parent. Instead, it is loaded in addition to the parent’s functions.php.

In that way, the functions.php of a child theme provides a smart, trouble-free method of modifying the functionality of a parent theme.

how to handle “cp: omitting directory ” error Ubuntu

While copying files from one location to another, you might get following error

$ sudo cp /home/code/wordpress /var/www/localfintrekking
cp: omitting directory '/home/code/wordpress'

Here is output of ls -la command

$ ls -la
total 84
drwxrwxr-x 21 USERNAME USERNAME 4096 Apr 20 23:18 .
drwxr-xr-x 45 USERNAME USERNAME 4096 May 7 14:12 ..
drwxrwxr-x 7 USERNAME USERNAME 4096 May 5 13:52 backup
drwxrwxr-x 15 USERNAME USERNAME 4096 Sep 21 2017 bootstrap
drwxrwxr-x 3 USERNAME USERNAME 4096 Mar 8 08:31 django
drwxrwxr-x 9 USERNAME USERNAME 4096 May 5 22:05 python
drwxrwxr-x 4 USERNAME USERNAME 4096 Apr 28 18:57 wordpress

By default, cp copies only the direct files in, and not sub directories in the directory. The message cp: omitting directory ‘directory’ warns you that the mentioned directory is not copied.

You solve this problem you can follow either of following command

sudo cp -r /home/code/wordpress /var/www/localtechtrekkingcom
sudo cp -a /home/code/wordpress /var/www/localtechtrekkingcom

Details about these options

-R, -r, --recursive
copy directories recursively

-a, --archive
same as -dR --preserve=all

Important note: Address needs to be route address and not the address from relative folder

Posting to Twitter using Python | Python Twitter Bot

Posting to twitter is very easy and you can directly use twitter API or you can use any library of your choice from twitter libraries page.

Here we are going to use our programming language of choice python and python library tweepy.

Step#1

Create a twitter app from https://apps.twitter.com/

Create Tweeter Application

  1. Please select unique application name. If anyone else has created application with same name, you will get error message.
  2. You can leave callback url empty

Step#2

Create access tokens as shown below

Create Access Tokens

Step#3 Unstall tweepy

I am using Python3.6 version, use following command to install tweepy

sudo python3.6 -m pip install tweepy

 

Step#4 Write Python program.

You can use following program for referencePython. This is working fine. You can modify as suited to your coding style and requirement.

# This is a sample tweeter bot program
# version : 0.1.0


import tweepy

def get_api(key_token):
auth = tweepy.OAuthHandler(key_token['consumer_key'], key_token['consumer_secret'])
auth.set_access_token(key_token['access_token'], key_token['access_token_secret'])
return tweepy.API(auth)

def main():
# Fill in the values noted in previous step here
key_token = { 
"consumer_key" : "some_value",
"consumer_secret" : "some_value",
"access_token" : "some_value",
"access_token_secret" : "some_value" 
}

api = get_api(key_token)

tweet = "Hello, world! This is first tweeter bot tweet"
status = api.update_status(status=tweet) 

if __name__ == "__main__":
main()

 

If you want to modify it further or want to add further options such as adding image along with text message, you please to following documentation

http://docs.tweepy.org/en/v3.5.0/

Feed free to let me know your feedback.