Paul's Programming Notes     Archive     Feed     Github

Writing To File - UnicodeEncodeError: 'ascii' codec can't encode characters

I was getting a lot of errors when I was trying to download a file with the python requests library. The errors looked like the following:

UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 2-6: ordinal not in range(128)

This code ended up fixing it:

Tunnel Traffic Through Webserver Using Your Browser

Use the following command in Cygwin (using your IP and Username, of course):

ssh -D 2280 -i your/certificate

Set the following settings in Firefox (connect settings, under the advanced tab):

proxy settings

Easyphp Change Directory To Github

1. Right click on the easyphp icon --> configuration --> apache (this should open the httpd.conf in your easyphp apache directory)

2. Find the section labelled DocumentRootDirectory and overwrite with this:

# DocumentRootDirectory
<Directory "C:/Users/your_username/Documents/GitHub/your_project/">
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    # The Options directive is both complicated and important.  Please see
    # for more information.
    Options Indexes FollowSymLinks Includes ExecCGI

    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    AllowOverride All

    # Controls who can get stuff from this server.
    Require all granted


Setting Up Github Windows Client Behind a Proxy

1. Navigate to your git.exe directory (C:\Users\your_username\AppData\Local\GitHub\PortableGit~\bin)

2. git config --global http.proxy http://username:password@host:port/

3. git config --system http.sslcainfo /bin/curl-ca-bundle.crt

4. Open the github client (it should work now)

move_uploaded_file To Current Path - PHP

$uploadfile = './' . basename($_FILES['file']['name']);

if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
echo "File was successfully uploaded.\n";
} else {
echo "There was an issue uploading the file.\n";