Very long string

Sometimes you need to test input with a long string and it is useful to easily see the index of each position so that you can see how much is read or tuncated or whatever.  Here is a handy string that I use.  It is divided up into 10 character blocks with no special characters or spacing (to see how wrapping will work or not work in some cases).  Each block starts with an “L” and ends with an “I” with “x”s and a number indicating position between.  This particular one is 1100 characters long, but it should be easy to extend or modify as needed.  Copy and paste is hella easier than making this by hand or using random characters that don’t indicate position easily.


Lxxxxxx10ILxxxxxx20ILxxxxxx30ILxxxxxx40ILxxxxxx50ILxxxxxx60ILxxxxxx70ILxxxxxx80ILxxxxxx90ILxxxxx100ILxxxxx110ILxxxxx120ILxxxxx130ILxxxxx140ILxxxxx150ILxxxxx160ILxxxxx170ILxxxxx180ILxxxxx190ILxxxxx200ILxxxxx210ILxxxxx220ILxxxxx230ILxxxxx240ILxxxxx250ILxxxxx260ILxxxxx270ILxxxxx280ILxxxxx290ILxxxxx300ILxxxxx310ILxxxxx320ILxxxxx330ILxxxxx340ILxxxxx350ILxxxxx360ILxxxxx370ILxxxxx380ILxxxxx390ILxxxxx400ILxxxxx410ILxxxxx420ILxxxxx430ILxxxxx440ILxxxxx450ILxxxxx460ILxxxxx470ILxxxxx480ILxxxxx490ILxxxxx500ILxxxxx510ILxxxxx520ILxxxxx530ILxxxxx540ILxxxxx550ILxxxxx560ILxxxxx570ILxxxxx580ILxxxxx590ILxxxxx600ILxxxxx610ILxxxxx620ILxxxxx630ILxxxxx640ILxxxxx650ILxxxxx660ILxxxxx670ILxxxxx680ILxxxxx690ILxxxxx700ILxxxxx710ILxxxxx720ILxxxxx730ILxxxxx740ILxxxxx750ILxxxxx760ILxxxxx770ILxxxxx780ILxxxxx790ILxxxxx800ILxxxxx810ILxxxxx820ILxxxxx830ILxxxxx840ILxxxxx850ILxxxxx860ILxxxxx870ILxxxxx880ILxxxxx890ILxxxxx900ILxxxxx910ILxxxxx920ILxxxxx930ILxxxxx940ILxxxxx950ILxxxxx960ILxxxxx970ILxxxxx980ILxxxxx990ILxxxx1000ILxxxx1010ILxxxx1020ILxxxx1030ILxxxx1040ILxxxx1050ILxxxx1060ILxxxx1070ILxxxx1080ILxxxx1090ILxxxx1100I

Derpy pathing

So, today I learned from a typo, that the GAE dev app server treats pathing defined in the @ApiMethod annotation differently than the cloud server.  In the dev app server, a path like either

path = “/endpoint”

path = “endpoint”

will resolve to

/_ah/api/whatevername/v1/endpoint

Where as the cloud GAE will resolve it as either

/_ah/api/endpoint

or

/_ah/api/whatevername/v1/endpoint

respectively.

This had me scratching my head for a while, but it is an interesting thing to remember and it may have some useful applications.

How to set up a proxy server on Google Compute (GCE)

There are times when a proxy server is necessary.  This article will not go into what a proxy server is or why you might need one, but this will give you step by step instructions on how to set up the squid proxy server on a Google Compute Engine (GCE) server.  This document assumes that you have a Google Cloud account and that you know how to set up a GCE server with Ubuntu.  Lines in a Fixed Width Font are commands that should be entered into the command shell.

This can be run on a GCE that has other things on it, but for personal use, a simple GCE f1-micro (1 vCPU, 0.6 GB memory) should be more than enough power.  Start your GCE and SSH into the machine to get a command line then do these simple steps.

  • Install squid
    • sudo apt install squid3
  • Install apache utils
    • sudo apt-get install apache2-utils
    • This Installs the htpasswd utility that allows for creating password files.
  • Copy the default configuration file to back it up.
    • sudo cp /etc/squid/squid.conf /etc/squid/squid.conf.original
  • Delete the old configuration file
    • sudo rm /etc/squid/squid.conf
    • This configuration file is ridiculously huge and has way more than any simple case would need.  We will just back it up and make a new one with only the information that we need.
  • Make a new configuration files
    • sudo vi /etc/squid/squid.conf
  • Enter this in the config file
    • auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwords
      auth_param basic realm proxy
      acl authenticated proxy_auth REQUIRED
      http_access allow authenticated

      # Choose the port you want. Default is 3128, but we set it to 8888
      http_port 8888

    • The first bit (4 lines) sets squid to require passwords
    • The last bit configures squid to use port 8888.  You can change this to anything you want.
    • Save the file in vi with [esc]:wq
  • Set up the username and password
    • sudo htpasswd -c /etc/squid/passwords [username]
    • Replace [username] with any username you want to use
    • You will be asked to enter and reenter a password for the username that you entered.  make sure they match.
  • Restart the squid service
    • sudo systemctl restart squid.service

You now have a proxy server.  🙂  To use it, you will need to find the external IP address for this GCE and use that along with the port that you set (8888 in this example) and the username and password that you set.

To make life easier, you may want to set an alias for starting squid.  To do that, do the following:

  • Open your bashrc file
    • vi ~/.bashrc
  • Scroll to the bottom of the file and add this line:
    • alias startsquid='sudo systemctl restart squid.service'
  • Save the file
    • [esc]:wq
  • reload your bashrc file so that you can use the new alias
    • . ~/.bashrc
    • that’s (period)(space)~/.bashrc
  • now you can restart it with the alias.
    • startsquid