Categories
Uncategorized

How To Simulate Network Issues on Windows

Hands down the easiest way to introduce network issues in applications on Windows is to use Clumsy. There is both a GUI and a command line interface available. The functionalities are as follows:

  1. Drop packets with a % chance
  2. Duplicate packets
  3. Add lag
  4. Make the packets go out of order
  5. Tamper packets

The GUI looks like the gif below but all the above commands are also available via command line interface.

clumsy-demo.gif
https://github.com/jagt/clumsy/blob/master/clumsy-demo.gif

How To Call Clumsy.exe From Terminal/CLI

It’s easy to miss the Wiki on Clumsy’s official Github page: https://github.com/jagt/clumsy/wiki/Command-Line-Arguments

The way to use it in 3 steps:

  1. First filter the and specify which IPs or Ports you want the settings to apply to.
  2. Then enable the different features lag/drop/duplicate… inbound or outbound.
  3. Then for each feature enabled specify the amount for each of them. This can be a number or percentage depending on the feature. For example lag is in number of Milliseconds while drop is in drop percentage chance.

Below is a sample execution of Clumsy.exe to drop all packets inbound or outbound over TCP port 443.

clumsy.exe --filter "tcp and (tcp.DstPort == 443 or tcp.SrcPort == 443)" --drop on --drop-inbound on --drop-outbound on --drop-chance 100.0

The best way to get used to it is to use the GUI version first. Then if you need to automate things use the CLI instead.

Categories
Uncategorized

How to curl on Windows

If you are trying to curl an external endpoint and have WSL then WSL will work. But because WSL runs in its own network you might not be able to curl from a WSL shell to, for example, a server on Windows. Don’t also download any curl executable from any third untrusted party.

Instead, the best solution is to just download Git Bash. From Git Bash you can call curl with all your favourite commands just like you usually do on Linux. Can’t believe I lost so much time on this! Hopefully you won’t. Nobody has time to learn Powershell’s nonsense invokerequest.

Categories
Administration

How To Kill All Nginx.exe Processes On Windows

Using tasklist, list all nginx.exe running on your machine. For that you need to open up a Windows Powershell terminal and run the following command:

 tasklist /fi "imagename eq nginx.exe"

This will give you an output which should resemble the table below:

Image Name PID Session Name Session# Mem Usage
========================= ======== ================ =========== ============
nginx.exe 6696 Console 4 8,724 K
nginx.exe 3156 Console 4 8,988 K
nginx.exe 12156 Console 4 8,420 K
nginx.exe 10724 Console 4 8,744 K

You can then use tasklist again to kill the processes. Notice the column Image Name. We can use that to filter and kill all nginx processes as follows:

taskkill /f /IM nginx.exe

This should kill all the nginx.exe processes. You can use the first command to verify that all of them have been terminated.

Categories
Development

How To: Python Sort Custom Comparator

As from Python 3.2 it is recommended to use functools.cmp_to_key() which has been added to the standard library to do sorting the “old way” with comparators.

This is also easier to read than confusing lambdas and easier to extend when you have more than 2 variables that need to be compared.

In the example below we are sorting a list of dictionaries based on their weights and prices. We are sorting them by prioritizing smaller weights and higher prices in this example.

list = [
    {"weight":10, "price": 10},
    {"weight":5, "price":20},
    {"weight": 10, "price": 21}
]

def compare(left, right):
    if left['weight'] < right['weight']: #prioritize smaller weight
        return -1
    elif left['weight'] == right['weight']:
        if left['price'] > right['price']: #but prioritize bigger prices
            return -1
        elif left['price'] == right['price']:
            return 0
        else:
            return 1
    else:
        return 1

from functools import cmp_to_key
sorted_list = sorted(list, key=cmp_to_key(compare), reverse=False)
print(sorted_list)

Notice that you also easily add a reverse parameter to automatically sort in the reverse order. This is handy for programming contests.

You can also provide a formula instead of -1,0 and 1 as result when comparing the left hand side with the right hand side. For example:

list = [
    {"weight":10, "price": 10},
    {"weight":5, "price":20},
    {"weight": 10, "price": 21}
]


def compare(left, right):
    return (left["weight"]*left["price"] - right["weight"]*right["price"])

from functools import cmp_to_key
sorted_list = sorted(list, key=cmp_to_key(compare), reverse=False)
print(sorted_list)

This is just an example and the way that the sorting is being done is basically the weight multiplied by the price, which is the smallest combination of (weight,price) first. Anyway, hope that this snippet has been useful to you.

We have more useful python articles that you can check:

How To Open A File In Python

Python Logging To CSV With Log Rotation and CSV Headers

Python logging json formatter

If you would like to learn more Python check out this certificate course by Google: IT Automation with Python

Categories
Development

How To Open A File In Python

This guide covers Opening A File In Python 3.9 and explains the different ways in which you can open a file in Python 3.9. This is likely to come useful a couple of times in the future, feel free to use/copy paste the code for your own purposes as you see fit.

file = open("filename.txt")

The most basic example shown above, opening a file in read-only text (rt) mode.

Method Signature Open In Python

You open a file in Python with the open function. There is nothing to import in Python 3.9. The method has the following signature:

def open(file, mode='r', buffering=None, encoding=None, errors=None, newline=None, closefd=True):

How To Specify File Path When Opening A File In Python?

It has 6 parameters, the first one is the path of the file that you want to open. This can be existing file if you are planning to read from a file or it can be new file that you plan to create by writing.

How To Specify The Mode When Opening A File In Python?

The second parameter refers to the different modes in which you can open the file. For example you can open a file in write mode with the following setting:

file = open("file.txt","w")

Find below a table to check the different modes available to open files in python that you can also combine together. For example the default mode is ‘rt’.

'r'       open for reading (default)
'w'       open for writing, truncating the file first
'x'       create a new file and open it for writing
'a'       open for writing, appending to the end of the file if it exists
'b'       binary mode
't'       text mode (default)
'+'       open a disk file for updating (reading and writing)
'U'       universal newline mode (deprecated)

Buffering When Opening A File In Python

The third parameter is buffering. By default buffering behaviour will depend on whether you are using binary or text mode to access the file. Files are read in fixed size chunks (buffering > 1) that you can specify and interactive text files are read by line (buffering=1). You can disable buffering by setting it to 0.

For example if you try to read a text file with buffering=0 you will get a ValueError: can’t have unbuffered text I/O error.

How To Specify Encoding When Opening A File In Python?

The fourth parameter encoding. This should only be used in text mode. You can find them at https://docs.python.org/3.9/library/codecs.html#standard-encodings

An example using encoding is as follows:

file = open("filename.txt","w", encoding="UTF8")

The fifth parameter is errors, related to the encoding. Errors is an optional string that specifies how encoding errors are to be handled—this argument should not be used in binary mode. Pass ‘strict’ to raise a ValueError exception if there is an encoding error (the default of None has the same effect), or pass ‘ignore’ to ignore errors. (Note that ignoring encoding errors can lead to data loss.)
See the documentation for codecs.register or run ‘help(codecs.Codec)’
for a list of the permitted encoding error strings.

Newline Considerations When Opening A File In Python

The sixth parameter is newline and this one also only works in text mode. The default mode is called Universal mode. Upon input, Lines ending with ‘\n’, ‘\r’, or ‘\r\n’ are translated into ‘\n’ before being returned to the caller.

What Does closefd Do When Opening A File In Python?

The final parameter clode. The important point is firstly that you can use a string or bytearray as a file for both reading and writing. Closefd has to be True for files and can be False when using the above mentioned types. If you try to set closefd as false for a file you will get the following error:

ValueError: Cannot use closefd=False with file name

That was it, let us know any specific articles on Python that you would like to see! If you want to check how to log in JSON with Python check this article: Python logging json formatter

Categories
Uncategorized

What Factors Affect The Prices Of Cryptocurrencies?

It is estimated as of mid 2021 that there are around 10,000 different types of cryptocurrencies. In order to find out what affects the prices of those cryptocurrencies we need to dive deeper into the different and most popular types of cryptocurrencies.

What Are The Most Frequently Traded Cryptocurrencies Based on Volume?

Based on Statistica, the top 5 traded cryptocurrency in 2021 are:

  1. Tether
  2. Bitcoin
  3. Ethereum
  4. Ripple
  5. Dogecoin

So let’s take a look each and what affects their prices.

What is Tether (USDT)?

The ticker for Tether is USDT, it is a Stablecoin and it is pegged to the US Dollar. By pegged this means that the price of Tether will vary based on the price of the US Dollar. 1 USD will always attempt to be equivalent to 1 Tether coin. If you want to know the formal definition of pegged and its purpose feel free to read more about it here: https://www.investopedia.com/terms/c/currency-peg.asp

What this means is that it should be unaffected, mostly, by the usual swings in the cryptocurrency market. This stability is where its main use lies. With Tether you can hold your cryptocurrencies in a more stable wallet.

So what affects the price of Tether coins? It’s the US Dollar.

What is Bitcoin BTC?

This is probably the most asked question about cryptocurrency. The technical details are complicated but the closest thing that you could compare it economically would be to Gold but at the same time it is much more in combination with the blockchain.

What affects the price of Bitcoin?

1. Limited Supply of Bitcoin

By Gold I mean that Bitcoin has a limited supply. There is a finite number of Bitcoin available. This limited supply is the main driver of its value right now.

2. Confidence / Adoption of Bitcoin

As services start to implement Bitcoin and it more widely adopted by users, more goods are traded against Bitcoin but also the confidence in the value that Bitcoin is bring is also going to affect its value. Similarly, when nobody thought Bitcoin had a future its value was low.

3. Speculation / Regulation / Public Opinion of Bitcoin

The price of Bitcoin also changes if more people are willing to buy them at a premium. This usually happens when individual traders decide to buy after may be a positive news regarding Bitcoin, like a tweet from Elon Musk or may be the Ukrainian parliament voting a bill on to legalize Bitcoin.

4. Large Financial Companies

Companies like Paypal investing more in Bitcoin has driven up the prices as well. This happened in 2020 where the Bitcoin value crossed 30,000 USD.

5. Wallet Hacks Negatively Impact Price Of Bitcoin

There many hacks that happen during a year on the wallets keeping the Bitcoins. Based on a research paper that you can read here: https://www.researchgate.net/figure/Historical-Price-of-Bitcoin-during-Mt-Gox-Hack-in-2014-9-Data-source-Coinmarketcapcom_fig1_341153855

Approximately one hundred cryptocurrency thefts, including hacks and scams, has occurred since 2012 to 2018, half of which are hacks of Bitcoin.

Security breaches of the cryptocurrency exchanges usually cause the price fluctuation in the market.

6. Mining Difficulty of Bitcoin Increases Price

Another factor that affects the price of both Ethereum and Bitcoin would be mining difficulty. The mining difficulty keeps on increasing exponentially, this means that more time and energy (electricity) is required to mine new Bitcoins and Ethereum.

What is Ethereum?

Moving on to the next cryptocurrency on the list. Both Ethereum and Bitcoin are traded, but the main different with Ethereum is that there is an infrastructure to have applications and contracts powered by Ether run on its blockchain.

In the case of Ethereum the same 5 factors as Bitcoins affects its price. You might also add innovation and adoption of the technology in application for Ethereum, however, it still has scalability issues to address.

What is Ripple Coin / XRP?

Ripple coin is used for payment purposes. It is used to facililate payment settlements and contrary to the other coins above you could call it a utility token. This is important to distinguish because you will usually buy XRP to pay for fees.

The supply for XRP is also different, it is planned by Ripple Labs that 1 billion new XRP will released every month. And also you don’t mine XRP. I will let you deduce your own conclusion here.

The main factor which affects XRP based on its ticker, is speculation. The highest it has been was in 2018 at around 3.4$ right when the news hit traders that financial institutions were adopting XRP and caused traders to rush to buy XRP.

What is Dogecoin?

This coin was created a joke (who would have guessed) to create a payment system. But this is why we all love the internet. Despite it being clearly a joke, if people see value in it then it will have value.

What affects the price of Dogecoin?

The factor which affects Dogecoin is, like you might have guessed already, speculation. A lot of traders are jumping into crypto with the fear of missing out and holding Dogecoin.

You can actually mine Dogecoin and the supply limit for Dogecoin is actually unlimited.

Summary

In short, research well into how different cryptocurrencies work and you should be able to figure out what affects the prices.

Categories
Uncategorized

How To Get Started At Dota 2

Dota 2 is a competitive game with a one of most toxic, woops, I mean demanding and experienced community. With now around 3000 hours into the game I realise how hard it can be for a new player to get started.

Below are a few principles that you can follow to get started and to get better at Dota 2. My advice is probably going to be unpopular and different from many guides online.

How To Queue In Dota 2

First part of the game is to actually queue for games. Here I would advise you to only queue for unranked games. But what types of game should you queue for? 1st unpopular advise is that you should choose Random Draft.

Random draft will force you to choose a random hero that you might not have picked before. As you spend time to experience new heroes, not only will you you enjoy the game more but you will also be able to become familiar with every hero’s ability.

The other thing to learn is, 1. what do you find easy and 2. what do you find hard when playing the hero. The reason is because if you find something hard with the hero, this means it is a possible disadvantage that you can exploit in a match where the opponent is using that hero.

How To Pick A Hero In Dota 2

After spending around 100 hours at least in the game you should now have experienced all the heroes. 100 hours is a lot for a typical game but not much for Dota 2. You can start to specialize. I would suggest that you have at least 3 different heroes as your go-to heroes to play. Ideally, a hero which can offlane, another which is a support and one which is carry.

Unpopular advice number 2 may be here, playing support is not actually easier than playing carry. Everyone has a preference, if you want to play carry then you should just start practicing that.

How To Play During Laning Phase In Dota 2 As A Support (Bottom or Top)

The advice here will vary based on the role type that you are playing and that is why I have kept a section for each. If you are a support your priorities will as follows:

  1. Allow your carry to get as much farm as possible
  2. Allow your carry to get as much experience as possible
  3. Deny as much farm as possible for the opposing side
  4. Deny as much experience as possible for the opposing side
  5. Provide as much vision as possible for your cores to make sure they are not surprised by ganks.

There are many things that you can do in order to do the above:

  1. Don’t hit creeps, your core is likely maintaining creep equilibrium(explained below)
  2. Learn timings to pull creep away from lane (check Youtube)
  3. If you have skills that can lower the HP for the opposing side use them
  4. Always keep salves, tangoes and clarities for your carry.

How To Play During Laning Phase In Dota 2 As A Core (Bottom or Top)

I would not advise you to play mid when starting Dota 2 because usually the mid core role is also known as a playmaker. You will need to develop enough game sense to play this particular role.

If you are playing Core in the Bottom lane or the Top lane then you need to make sure of the following:

  1. Maintain creep equilibrium – This means that you should make sure that the creeps are always near your tower but never within the attack range of the tower. This is because if you are closer to your tower it easier for you to escape any gank attempts and closer to help when someone teleports to help you.
  2. Learn to last hit and to deny creeps. This will take time and practice but this is an important part of laning and farming.
  3. Learn the strengths and weakness of your hero. Not only practice but also read guides on https://liquipedia.net/dota2/ for every hero that you play.

How To Play Mid In Dota 2

You will need to both know your hero and your opponent’s hero inside and out in order to win middle lane. For example, if you are a Shadow Fiend laning against a melee hero you are at a big advantage. There are several matchups like this in Dota 2 that you can read about in https://liquipedia.net/dota2/ or experience as you play more.

In case you are against a bad matchup and are struggling to win the lane, don’t feel bad it can happen even the best. But this means that you need to have a backup plan. I often see players failing to adapt to the situation and continuing to fail the lane.

This is where know your hero comes into play. Here are a few things that you can try if you are losing the lane:

  1. Get a bottle. When you have a bottle and click on a rune, your bottle will fill up. Although bounty runes only fill up half of the bottle.
  2. Know the rune timings, of course check the patches because this changes all the time now. First rune is at 2 minutes, second at 4 minutes and every 2 minutes. You also have bounty runes every 3rd minute The first 2 runes appear on both sides of the river. They are mana runes that you can use to replenish your mana, this means you can use spells to harass your opponent and go for those runes. At minute six if you are lucky you could get a Double Damage Rune which can allow you to change the tide in mid or if you get a Haste Rune you can use that to gank an adjacent lane
  3. Once you hit a certain timing for your hero, let’s say level 6 on Nyx Assassin for example you can start to gank other lanes and to make plays.

How to play Early Game in Dota 2

You need to be clear about your objectives in early game. Usually it is winning your laning phase but you always need to reassess your situation.

For example is your carry getting farm and experience? Do we have enough vision on the map? Is a particular lane “feeding” that requires your help? Always asks these questions to maximise your impact in the game. Dota 2 cannot be won on your own, it’s a team game.

Usually it is a good idea to secure or defend towers. Why you might ask?

Why Is It So Good To Secure Towers In Dota 2?

Well when a tower is destroyed the map opens for you to gank your opponent. For example the middle lane is a every good example. When you destroy the tower mid you can more easily enter the enemy territory to get kills or to ward to predict the movement of the enemy.

The bottom and top towers should be defending to provide more security for your carry to farm (or destroyed to remove that security for the enemy team). What security you might ask? Well:

  1. firstly the tower gives vision.
  2. Secondly the tower now gives armor, regen and it is easy to farm under
  3. Your teammates can teleport to the tower if you(carry) are getting ganked for example.

How To Play Middle Game In Dota 2

Middle game is all about timings. Have you hit a particular talent or ability timing that makes your hero particularly strong? Or have you hit a particular timing for your items like Ethereal blade for Morphling.

You should make sure that you know the timings for heroes that your teammates are also using. You will develop an intuition for that as you play different heroes because just reading Liquipedia is too boring and nobody does that let’s be frank.

A tip here is to not stop your vision game. Make sure to remember to ward and deward.

How To Play Late Game In Dota 2

One thing to realise here is that mistakes in Late Game are way more costly than mistakes at any other stage in the game. Getting killed alone by the team for example if you are a Tidehunter might mean that the opposing team now has a window of opportunity to push towers and provoke a fight with your team. Or worse, losing a teamfight might mean that the other team has an opportunity to push and take racks.

You should always keep an eye on buyback. To know whether to keep money for buyback or to buy a key item is always going to be based on experience and hard to guide around.

There are many decisions to make in the late game and the hardest part is to make the decisions as a team. Hopefully you have developed a bond with your team mates at this of the game and a sense of how they play. You usually will.

Bonus: How To Deal With Toxic Players

Try to party with friends as much as possible. If you don’t have them yet try to join communities, local groups on Facebook or other people. You might be surprised at the number of current players who would like to coach you.

Thankfully, Dota 2 has a mute feature where you can mute both the voice, text and pings from other Toxic players. You can open the Window by clicking on the Hamburger icon top left of the screen. An additional advice is that you can press F9 to unpause should there be someone who likes to pause and talk nonsense. Personally I mute everyone (own team and enemy team) at the start of every game and put a playlist of music.

This is the best way that I have found that has helped me enjoy the game for a long, because you need to realise that at the end of the day you are playing Dota 2 to enjoy yourself.

Note: There is so much more that I want to add to this guide but I feel I have already written too much. Depending on the views on this guide I will consider writing a bit more. Let me know if these basic principles help you.

Categories
Uncategorized

Is Dota 2 Dying? 2021

Dota has survived more than a decade and Dota 2 officially came out in 2013 (open beta in 2012). The short answer is No. In order to explain why Dota 2 is not dying we will need to look at several stats from Steam and Twitch.

Steam 2013 Dota 2

Dota 2 is finally coming out of beta and being officially released. During this year we average around 300,000 players. Many are still playing Dota 1 and probably not making the switch yet. Many heroes are yet to be implemented.

Steam 2016 Dota 2

From 2013 to 2016, Dota 2 experienced a steady increase in player number from 300,000 to an amazing 700,000. To put this into perspective the max average number of players Warframe, another popular game, has ever amassed is only 154,000 (Steam and other platforms like PS4 included) and by no means can we say it is dying.

Steam 2021 Dota 2

Fast forward to right now Dota 2’s average player base has now stabilized to 400,000. If you have played Dota 2 you probably know the ruthlessness of the old players who expect new players to perform well in matches. This can often be seen as toxic behaviour by newer/younger players.

Valve has a done a great job here to improve the experience and I think this has reflected positively on the number we see above.

Twitch Dota

1 million peak viewers on Twitch is just during The International we should discard that because this includes viewers from other games.

If you go on Twitch right now and look at the number of viewers for Dota 2 you might see a meager number like 50,000. Even if you find the viewership for the largest internationals you will notice that they only climb to maximum 150,000 average viewers. This number can easily deceive you into thinking Dota 2 is dying compared to other games like League of Legends.

Twitch viewership has nothing to do with the actual user base.

Firstly because Dota 2 players can spectate professional games from inside the game itself.

Secondly because most of the Dota 2 players, I think, are now probably in their 30s with thousands of hours invested in the game. I personally don’t find it enjoyable to look at a pro player playing a solo game on Twitch.

At this point you understand that a real Dota 2 match is played with between good teams and you will only be watching tournaments ( that too only big ones which competent teams).

Bonus: New Dota 2 Servers

If you are an African you already know this(like me). Valve has done great job adding more servers. For example, in the past we did not have a South African server so many of us had to queue in Europe. If you are from Europe and are now experiencing longer wait times it might be because now we have our own servers ?. Just kidding (not really though), this is a good sign for the future of Dota 2.

I really love this game and hope that it continues to live for at least another 2 decades. So far, no signs of Dota 2 dying!

Categories
Development

Free AMP WordPress Theme with 2 Sidebars

You might have noticed that this WordPress website is fully AMP compatible. We actually made a child theme of the popular TwentyTwenty theme to improve Google Search ranking, improve page experience on desktop/mobile and increase revenue from Google AdSense (20%). This theme does 3 things:

  1. Perfect Core Web Vitals, Page experience and Mobile experience score using minimal CSS modification.
  2. Adds 2 sidebars!
  3. Can be easily converted to be fully AMP with the official AMP plugin for WordPress.
Example adding AMP Ads in the sidebar

What are the changes made?

functions.php



add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
    $parenthandle = 'parent-style';
    $theme = wp_get_theme();
    wp_enqueue_style( $parenthandle, get_template_directory_uri() . '/style.css', 
        array(), 
        $theme->parent()->get('Version')
    );
    wp_enqueue_style( 'child-style', get_stylesheet_uri(),
        array( $parenthandle ),
        $theme->get('Version') // this only works if you have Version in the style header
    );
}

Takes the style.css of the parent theme and then uses its own style.css

if (function_exists('register_sidebars'))
    register_sidebars(4);

By default there are 2 places already where you can add widget to the TwentyTwenty theme. This is footer 1 and footer 2. This code then registers a total of 4 sidebars, that is, an additional 2.

template-parts/content.php



	<main id="main">
		<aside class="sidebar">
			<?php if (function_exists('dynamic_sidebar') && dynamic_sidebar(3) ){} ?>

		</aside>
		<div class="main-content">
			<div class="post-inner <?php echo is_page_template( 'templates/template-full-width.php' ) ? '' : 'thin'; ?> ">
				<div class="entry-content">
					<?php
					if ( is_search() || ! is_singular() && 'summary' === get_theme_mod( 'blog_content', 'full' ) ) {
						the_excerpt();
					} else {
						the_content( __( 'Continue reading', 'twentytwenty' ) );
					}
					?>
				</div><!-- .entry-content -->
			</div><!-- .post-inner -->
		</div>
		<aside class="sidebar">
			<?php if (function_exists('dynamic_sidebar') && dynamic_sidebar(4) ) {}?>
		</aside>
	</main>

This code is responsible for displaying the content for pages. Here we have separated the page in 3 parts:

  1. <aside class=”sidebar”></aside>
  2. <div class=”main-content”></div>
  3. <aside class=”sidebar”></aside>

You will notice that the aside html elements contain PHP code which are injecting any Widgets that you can add in the admin dashboard at Appearance->Widgets->sidebar 3 or 4.

style.css

In the style.css we define important values in order to meet several requirements set by Google for UI requirements to have perfect core web vitals as described in this post.

The important part however is that we separate the following:



/*
Sidebar stuff
*/
@media only screen and (min-width: 1280px) {
    #main {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    .single .main-content {
        width: 60%;
    }
    #main > .sidebar {
        padding-top: calc(1rem * 1.5);
        width: calc(20% - 2rem);
        margin-top: 1rem;
        text-align: center;
		display: block;
    }
	#main > .aside {
        display: block;
    }
	#main > .sidebar > li {
		list-style-type: none;
	}
}
@media only screen and (max-width: 1279px) {
    #main > .sidebar {
        display: none;
    }
}
.wp-block-code {
	background-color: white !important;
}
p {
	font-family: "trebuchet ms", verdana, helvetica, arial, sans-serif;	
}

The important part in this CSS code is that for devices with screen size of 1280px wide and above; we are separating the page into 3.

  1. 20% left sidebar
  2. 60% main content
  3. 20% right sidebar

We then have a few rules of hiding the sidebars incase we have smaller screens. Note that this means if you want to put ads in the sidebars you should go ahead with responsive ads or amp ads. This is because hiding normal ads with display:none in AdSense is not allowed.

Feel free to download, zip and install the theme. The code is at https://github.com/Lougarou/twentytwenty-but-has-sidebars.

Categories
Administration

How To Access WordPress Logs From Docker

If you are using the official Docker compose file or the modified one from the previous post then it is easy to access the logs.

1. Using Docker logs <container-id>

First from the terminal list all docker containers which are running docker ps. This should give you an output similar to the one in the screenshot below:

The first column shows the container-id which we are interested in here. Next you just need to type docker logs d2c3e6066616 and replace d2c3e6066616 with your own container id.

2. Using Docker exec -it /bin/bash

The other way is to actually access the Docker containers and peak inside for the logs. For example in this case:

docker exec -it docker exec -it d2c3e6066616 /bin/bash/bin/bash

Of course replace d2c3e6066616 with your own container-id again. For the WordPress Docker container the logs should be in /var/log/apache2 and the MySQL container the logs should in /var/log/mysql.

Alternatively you could also mount the whole thing to a host volume.