bash – base64 decode command linux cli command

bash – base64 decode command linux cli command

Usage:

man base64

base64 file.txt > encoded.txt # to encode
base64 -d encoded.txt > decoded.txt  # to decode

You can also use

cat file.txt | base64 # to encode
cat encoded.txt | base64 -d # to decode

Note:

If you get base64: INVALID INPUT error, that means your input file is not a base64 encoded file( it can not be decoded with base64). Example try to decode your text file.

base64 -d file.txt

Output:

base64: invalid input

bash – base64 decode command linux cli command

bash – base64 decode command linux cli command

Python: urllib.error.HTTPError: HTTP Error 404: Not Found

Python: urllib.error.HTTPError: HTTP Error 404: Not Found

So apparently the default display number of questions per page is 50 so the range you defined in the loop goes out of the available number of pages with 50 questions per page. The range should be adapted to be within the number of total pages with 50 questions each.

This code will catch the 404 error which was the reason you got an error and ignore it just in case you go out of the range.

from urllib.request import urlopen

def find_bad_qn(a):
    url = https://stackoverflow.com/questions?page= + str(a) + &sort=active
    try:
        urlopen(url)
    except:
        pass

print(Please Wait.. it will take some time)
for i in range(298314,298346):
    find_bad_qn(i)

I have exactly the same problem. The url that I want to get using urllib exists and is accessible using normal browser, but urllib is telling me 404.

The solution for me is not use urllib:

import requests
requests.get(url)

This works for me.

Python: urllib.error.HTTPError: HTTP Error 404: Not Found

Python: urllib.error.HTTPError: HTTP Error 404: Not Found

The default User-Agent doesnt seem to have as much access as Mozilla.

Try importing Request and append , headers={User-Agent: Mozilla/5.0} to the end of your url.

ie:

from urllib.request import Request, urlopen    
url = fhttps://stackoverflow.com/questions?page={str(a)}&sort=active    
req = Request(url, headers={User-Agent: Mozilla/5.0})    
html = urlopen(req)

How to move Docker containers between different hosts?

How to move Docker containers between different hosts?

Alternatively, if you do not wish to push to a repository:

  1. Export the container to a tarball
    docker export <CONTAINER ID> > /home/export.tar
    
  2. Move your tarball to new machine
  3. Import it back
    cat /home/export.tar | docker import - some-name:latest
    

You cannot move a running docker container from one host to another.

You can commit the changes in your container to an image with docker commit, move the image onto a new host, and then start a new container with docker run. This will preserve any data that your application has created inside the container.

Nb: It does not preserve data that is stored inside volumes; you need to move data volumes manually to new host.

How to move Docker containers between different hosts?

What eventually worked for me, after lots of confusing manuals and confusing tutorials, since Docker is obviously at time of my writing at peek of inflated expectations, is:

  1. Save the docker image into archive:
    docker save image_name > image_name.tar
  2. copy on another machine
  3. on that other docker machine, run docker load in a following way:
    cat image_name.tar | docker load

Export and import, as proposed in another answers does not export ports and variables, which might be required for your container to run. And you might end up with stuff like No command specified etc… When you try to load it on another machine.

So, difference between save and export is that save command saves whole image with history and metadata, while export command exports only files structure (without history or metadata).

Needless to say is that, if you already have those ports taken on the docker hyper-visor you are doing import, by some other docker container, you will end-up in conflict, and you will have to reconfigure exposed ports.

Note: In order to move data with docker, you might be having persistent storage somewhere, which should also be moved alongside with containers.

Related Posts

ibm cloud infrastructure – How to set up PPTP VPN for Windows 7 in Softlayer

ibm cloud infrastructure – How to set up PPTP VPN for Windows 7 in Softlayer

The next links provide great information on VPN:

https://knowledgelayer.softlayer.com/procedure/set-pptp-vpn-windows-7

http://www.softlayer.com/VPN-Access

http://knowledgelayer.softlayer.com/procedure/getting-started-softlayer-vpn

ibm cloud infrastructure – How to set up PPTP VPN for Windows 7 in Softlayer

Related Posts

No module named openpyxl – Python 3.4 – Ubuntu

No module named openpyxl – Python 3.4 – Ubuntu

@zetysz and @Manish already fixed the problem. I am just putting this in an answer for future reference:

  • pip refers to Python 2 as a default in Ubuntu, this means that pip install x will install the module for Python 2 and not for 3
  • pip3 refers to Python 3, it will install the module for Python 3

If you dont use conda, just use :

pip install openpyxl

If you use conda, Id recommend :

conda install -c anaconda openpyxl

instead of simply conda install openpyxl

Because there are issues right now with conda updating (see GitHub Issue #8842) ; this is being fixed and it should work again after the next release (conda 4.7.6)

No module named openpyxl – Python 3.4 – Ubuntu

In order to keep track of dependency issues, I like to use the conda installer, which simply boils down to:

conda install openpyxl

Also Check No module named openpyxl – Python 3.4

windows – starting R: Error: U used without hex digits in character string starting C:U

windows – starting R: Error: U used without hex digits in character string starting C:U

I was able to solve this after all:

I had a section inside my .Rprofile file (in Documents) with instead of /.
So I now changed

# Set mainfolder for PACKAGE package
options(PACKAGE_MAINFOLDER=C:Users...)

to

# Set mainfolder for PACKAGE package
options(PACKAGE_MAINFOLDER=C:/Users/...)

and that did the trick.

To make it work, just remove the C:Usersedmar.campos.cardosoDropbox and replace all with / using the function setwd() to change the working directory in R.

Wrong way:

setwd(C:Usersedmar.campos.cardosoDropbox...)

Right way:

setwd(/Users/edmar.campos.cardoso/Dropbox/...)

windows – starting R: Error: U used without hex digits in character string starting C:U

You can use \ instead of . This allows skipping from some characters such as n which is the end of the line or t which is tab.

Related Posts

Can you still get Toshiba laptops?

Can you still get Toshiba laptops?

Toshiba has confirmed that it will no longer be making laptops, transferring its remaining share of PC business to Sharp. In a short statement, Toshiba said that it had transferred its 19.9 percent of outstanding shares in Dynabook brand.

Python Regex Error : nothing to repeat at position 0

Can old Toshiba laptops be upgraded?

You cannot upgrade the CPU because it is soldered into the motherboard. If you want better gaming performance, then you really do not have any other choice than to buy a laptop that is more capable of playing games.

Why did they stop making Toshiba laptops?

During the 1990s and early 2000s Toshiba was among the top PC manufacturers, but as more players crowded into the market and with fewer unique features to offer, Toshibas laptops waned in popularity.

Does Toshiba still make laptops in

Toshiba no longer makes consumer laptops and has shifted focus to business systems. Our list below should guide you accordingly so you can pick the best Toshiba laptop alternative for your budget and needs. 2019 Apple MacBook Pro (16-inch, 16GB RAM,

Are Toshiba still making laptops?

Toshiba no longer makes consumer laptops and has shifted focus to business systems.

What replaced Toshiba laptops?

Because Toshiba Laptops has been rebranded as Dynabooks America, the Toshiba Satellite line is technically now the Dynabook Satellite line, but the philosophy of the line is unchanged. Theyre squarely aimed at those looking for an affordable laptop, with prices anywhere from $499 to $899.

Do they still make Toshiba?

Eventually Toshiba fully exited from the personal computing market in June 2020, transferring the remaining 19.9% shares in Toshiba Client Solutions (since being renamed to Dynabook Inc.) to Sharp.

What are Toshiba laptops called now?

Toshiba had used the brand name DynaBook or dynabook since 1989, but Dynabook became the worldwide brand in 2019.

How can I speed up my old Toshiba laptop?

There are a few techniques that can speed up your system, including deleting programs, defragmenting the hard drive, and expanding available memory. Also, if all else fails, you may delete the contents of the hard drive and reset the laptop to original factory conditions.

What can I do with my old Toshiba laptop?

The Laptop is a TOSHIBA Satellite C655-S5132. If Windows 11 can run on an 11 year old laptop as someone else mentioned, then it can run on this one

Does Toshiba still sell laptops?

Toshiba no longer makes consumer laptops and has shifted focus to business systems.

When did they stop making Toshiba laptops?

As of August 2020, the company is no longer producing any laptops under its own brand name.

What has happened to Toshiba?

Because Toshiba Laptops has been rebranded as Dynabooks America, the Toshiba Satellite line is technically now the Dynabook Satellite line, but the philosophy of the line is unchanged. Theyre squarely aimed at those looking for an affordable laptop, with prices anywhere from $499 to $899.

Are Toshiba laptops still available?

Toshiba has confirmed that it will no longer be making laptops, transferring its remaining share of PC business to Sharp. In a short statement, Toshiba said that it had transferred its 19.9 percent of outstanding shares in Dynabook brand.

Is Toshiba coming back?

As of August 2020, the company is no longer producing any laptops under its own brand name.

Who makes Toshiba laptops now?

Toshiba no longer makes consumer laptops and has shifted focus to business systems.

What is a good replacement for a Toshiba Satellite laptop?

Toshiba had used the brand name DynaBook or dynabook since 1989, but Dynabook became the worldwide brand in 2019.

Do Toshiba still make laptops?

Our list below should guide you accordingly so you can pick the best Toshiba laptop alternative for your budget and needs. 2019 Apple MacBook Pro (16-inch, 16GB RAM, HP ENVY 13-13.99 Inches Thin Laptop w/ ASUS ZenBook 14 Ultra-Slim Laptop 14 Full

Is Toshiba discontinued?

The Japanese giant Toshiba has sold its final stake in the personal computer maker Dynabook. It means the firm no longer has a connection with making PCs or laptops. Sharp bought 80% of Toshibas personal computing arm in 2018 for $36m (xa327m), and has now bought the remaining shares, Toshiba said in a statement.

Why did Toshiba stop?

Toshiba had used the brand name DynaBook or dynabook since 1989, but Dynabook became the worldwide brand in 2019.

Does Toshiba still make electronics?

During the 1990s and early 2000s Toshiba was among the top PC manufacturers, but as more players crowded into the market and with fewer unique features to offer, Toshibas laptops waned in popularity.

Does Toshiba still make laptops?

Because Toshiba Laptops has been rebranded as Dynabooks America, the Toshiba Satellite line is technically now the Dynabook Satellite line, but the philosophy of the line is unchanged. Theyre squarely aimed at those looking for an affordable laptop, with prices anywhere from $499 to $899.

Does Toshiba still make laptops 2020?

Toshiba no longer makes consumer laptops and has shifted focus to business systems.

Why is Toshiba called dynabook?

Toshiba has confirmed that it will no longer be making laptops, transferring its remaining share of PC business to Sharp. In a short statement, Toshiba said that it had transferred its 19.9 percent of outstanding shares in Dynabook brand.

Can an old Toshiba laptop be upgraded?

Yes. All Upgradeable memory that is advertised for Toshiba is model specific

Python 3 TypeError: must be str, not bytes with sys.stdout.write()

Python 3 TypeError: must be str, not bytes with sys.stdout.write()

type errr

Python 3 handles strings a bit different. Originally there was just one type for
strings: str. When unicode gained traction in the 90s the new unicode type
was added to handle Unicode without breaking pre-existing code1. This is
effectively the same as str but with multibyte support.

In Python 3 there are two different types:

  • The bytes type. This is just a sequence of bytes, Python doesnt know
    anything about how to interpret this as characters.
  • The str type. This is also a sequence of bytes, but Python knows how to
    interpret those bytes as characters
    .
  • The separate unicode type was dropped. str now supports unicode.

In Python 2 implicitly assuming an encoding could cause a lot of problems; you
could end up using the wrong encoding, or the data may not have an encoding at
all (e.g. it’s a PNG image).
Explicitly telling Python which encoding to use (or explicitly telling it to
guess) is often a lot better and much more in line with the Python philosophy
of explicit is better than implicit.

This change is incompatible with Python 2 as many return values have changed,
leading to subtle problems like this one; its probably the main reason why
Python 3 adoption has been so slow. Since Python doesnt have static typing2
its impossible to change this automatically with a script (such as the bundled
2to3).

  • You can convert str to bytes with bytes(h€llo, utf-8); this should
    produce bHxe2x82xacllo. Note how one character was converted to three
    bytes.
  • You can convert bytes to str with bHxe2x82xacllo.decode(utf-8).

Of course, UTF-8 may not be the correct character set in your case, so be sure
to use the correct one.

In your specific piece of code, nextline is of type bytes, not str,
reading stdout and stdin from subprocess changed in Python 3 from str to
bytes. This is because Python cant be sure which encoding this uses. It
probably uses the same as sys.stdin.encoding (the encoding of your system),
but it cant be sure.

You need to replace:

sys.stdout.write(nextline)

with:

sys.stdout.write(nextline.decode(utf-8))

or maybe:

sys.stdout.write(nextline.decode(sys.stdout.encoding))

You will also need to modify if nextline == to if nextline == b since:

>>>  == b
False

Also see the Python 3 ChangeLog, PEP 358, and PEP 3112.


1 There are some neat tricks you can do with ASCII that you cant do with multibyte character sets; the most famous example is the xor with space to switch case (e.g. chr(ord(a) ^ ord( )) == A) and set 6th bit to make a control character (e.g. ord(t) + ord(@) == ord(I)). ASCII was designed in a time when manipulating individual bits was an operation with a non-negligible performance impact.

2 Yes, you can use function annotations, but its a comparatively new feature and little used.

While the accepted answer will work fine if the bytes you have from your subprocess are encoded using sys.stdout.encoding (or a compatible encoding, like reading from a tool that outputs ASCII and your stdout uses UTF-8), the correct way to write arbitrary bytes to stdout is:

sys.stdout.buffer.write(some_bytes_object)

This will just output the bytes as-is, without trying to treat them as text-in-some-encoding.

Python 3 TypeError: must be str, not bytes with sys.stdout.write()

How to disable Python warnings?

How to disable Python warnings?

notebook

Look at the Temporarily Suppressing Warnings section of the Python docs:

If you are using code that you know will raise a warning, such as a deprecated function, but do not want to see the warning, then it is possible to suppress the warning using the catch_warnings context manager:

import warnings

def fxn():
    warnings.warn(deprecated, DeprecationWarning)

with warnings.catch_warnings():
    warnings.simplefilter(ignore)
    fxn()

I dont condone it, but you could just suppress all warnings with this:

import warnings
warnings.filterwarnings(ignore)

Ex:

>>> import warnings
>>> def f():
...     print(before)
...     warnings.warn(you are warned!)
...     print(after)
...
>>> f()
before
<stdin>:3: UserWarning: you are warned!
after
>>> warnings.filterwarnings(ignore)
>>> f()
before
after

Theres the -W option.

python -W ignore foo.py

How to disable Python warnings?

You can also define an environment variable (new feature in 2010 – i.e. python 2.7)

export PYTHONWARNINGS=ignore

Test like this: Default

$ export PYTHONWARNINGS=default
$ python
>>> import warnings
>>> warnings.warn(my warning)
__main__:1: UserWarning: my warning
>>>

Ignore warnings

$ export PYTHONWARNINGS=ignore
$ python
>>> import warnings
>>> warnings.warn(my warning)
>>> 

For deprecation warnings have a look at how-to-ignore-deprecation-warnings-in-python

Copied here…

From documentation of the warnings module:

 #!/usr/bin/env python -W ignore::DeprecationWarning

If youre on Windows: pass -W ignore::DeprecationWarning as an argument to Python. Better though to resolve the issue, by casting to int.

(Note that in Python 3.2, deprecation warnings are ignored by default.)

Or:

import warnings

with warnings.catch_warnings():
    warnings.filterwarnings(ignore, category=DeprecationWarning)
    import md5, sha

yourcode()

Now you still get all the other DeprecationWarnings, but not the ones caused by:

import md5, sha

python – How to terminate a script?

python – How to terminate a script?

Python-Terminate-Program-Example-using-sys.exit-Method

import sys
sys.exit()

details from the sys module documentation:

sys.exit([arg])

Exit from Python. This is implemented by raising the
SystemExit exception, so cleanup actions specified by finally clauses
of try statements are honored, and it is possible to intercept the
exit attempt at an outer level.

The optional argument arg can be an integer giving the exit status
(defaulting to zero), or another type of object. If it is an integer,
zero is considered “successful termination” and any nonzero value is
considered “abnormal termination” by shells and the like. Most systems
require it to be in the range 0-127, and produce undefined results
otherwise. Some systems have a convention for assigning specific
meanings to specific exit codes, but these are generally
underdeveloped; Unix programs generally use 2 for command line syntax
errors and 1 for all other kind of errors. If another type of object
is passed, None is equivalent to passing zero, and any other object is
printed to stderr and results in an exit code of 1. In particular,
sys.exit(some error message) is a quick way to exit a program when
an error occurs.

Since exit() ultimately “only” raises an exception, it will only exit
the process when called from the main thread, and the exception is not
intercepted.

Note that this is the nice way to exit. @glyphtwistedmatrix below points out that if you want a hard exit, you can use os._exit(*errorcode*), though its likely os-specific to some extent (it might not take an errorcode under windows, for example), and it definitely is less friendly since it doesnt let the interpreter do any cleanup before the process dies. On the other hand, it does kill the entire process, including all running threads, while sys.exit() (as it says in the docs) only exits if called from the main thread, with no other threads running.

A simple way to terminate a Python script early is to use the built-in quit() function. There is no need to import any library, and it is efficient and simple.

Example:

#do stuff
if this == that:
  quit()

python – How to terminate a script?

Another way is:

raise SystemExit