Thursday, March 19, 2020

Collapse Of The Second Reich Essay

Collapse Of The Second Reich Essay Collapse Of The Second Reich Essay The collapse of the autocratic Kaiserreich The Kaiserreich was autocratic in nature; this meant that the Kaiser had ultimate power over Germany. Although a Parliament (the Reichstag) was established, there was no parliamentary Government – all ministers were appointed by the Kaiser Wilhelm II. Pressure from German public: At the beginning of World War One, German citizens rallied to support their nation. In 1916, however, discontent was growing in Germany as the death rate soared and shortages intensified. A period referred to as the ‘turnip winter’ in 1916-17 saw turnips become the staple diet of citizens. The Russian Revolution was influential to the German working class, the overthrow of the tsar and his demise somewhat inspired many Germans and there were calls for a parliamentary Government. Pressure from Reichstag: The Great Depression in Germany, not only undermined the loyalty of the German public but also the politicians. There was no longer unanimous support in the Reichstag for massive expenditure. In July 1917, a dramatic parliamentary revolt occurred when a peace resolution was carried by 212 votes to 126 – this peace resolution was disregarded by the High Command. Pressure from USA: Germany increased its war efforts during the Turnip Winter of 1916-17 and announced that U-boats would attack every ship in Europe’s waters. In response to this, US president Wilson ended all diplomatic relations with Germany. President Wilson’s neutral position was no longer deemed appropriate and many in the US now saw war as a viable solution. When the German Foreign Secretary sent the ‘Zimmerman note’ to Mexico requesting that Mexico declare war on the US if the US declared war on Germany, promising the states of Texas, Arizona and New Mexico at the end of the war, the American public were outraged. Finally, on 18th March 1917, German U-boats sank three American ships and President Wilson entered World War One alongside the Allied forces. Wilson declared that the US were fighting on a moral basis only: to ‘protect democracy from tyranny and promote peace throughout the world’. 3,000,000 US men were drafted to bolster the military and Wilson was pleasantly surprised to find that many Americans supported his action. Wilson appointed General John J. Pershing as commander of US forces in Europe and left all operational decisions under his jurisdiction. When the American Government launched a propaganda campaign to persuade less enthusiastic Americans to support the war, the campaign also fuelled anti-German sentiments and a deep loathing for Germany and its people. In response, Wilson reminded the people that the US had

Tuesday, March 3, 2020

Use OptionParser to Parse Commands in Ruby

Use OptionParser to Parse Commands in Ruby In the article discussing OptionParsers features we discussed some of the reasons that make using OptionParser in Ruby preferable to looking through ARGV manually to parse commands by hand. Now its time to get down to learning how to use OptionParser and its features. The following boilerplate code will be used for all the examples in this tutorial. To try any of the examples, simply put the examples opts.on block next to the TODO comment. Running the program will print the state of the options has and ARGV, allowing you to examine the effects of your switches. #!/usr/bin/env rubyrequire optparserequire pp# This hash will hold all of the options# parsed from the command-line by# OptionParser.options {}optparse OptionParser.new do|opts|# TODO: Put command-line options here# This displays the help screen, all programs are# assumed to have this option.opts.on( -h, help, Display this screen ) doputs optsexitendend# Parse the command-line. Remember there are two forms# of the parse method. The parse method simply parses# ARGV, while the parse! method parses ARGV and removes# any options found there, as well as any parameters for# the options. Whats left is the list of files to resize.optparse.parse!pp Options:, optionspp ARGV:, ARGV Simple Switch A simple switch is an argument with no optional forms or no parameters. The effect will be to simply set a flag in the options hash. No other parameters will be passed to the on method. options[:simple] falseopts.on( -s, simple, Simple argument ) dooptions[:simple] trueend Switch with Mandatory Parameter Switches that take a parameter only need to state the parameter name in the long form of the switch. For example, -f, file FILE means the -f or file switch takes a single parameter called FILE, and this parameter is mandatory. You cannot use either -f or file without also passing it a parameter. options[:mand] opts.on( -m, mandatory FILE, Mandatory argument ) do|f|options[:mand] fend Switch with Optional Parameter Switch parameters dont have to be mandatory, they can be optional. To declare a switch parameter optional, place its name in brackets in the switch description. For example, logfile [FILE] means the FILE parameter is optional. If not supplied, the program will assume a sane default, such as a file called log.txt. In the example, the idiom a b || c is used. This is just shorthand for a b, but if b is false or nil, a c. options[:opt] falseopts.on( -o, optional [OPT], Optional argument ) do|f|options[:opt] f || nothingend Automatically Convert to Float OptionParser can automatically convert argument to some types. One of these types is Float. To automatically convert your arguments to a switch to Float, pass Float to the on method after your switch description strings. Automatic conversions are handy. Not only do they save you the step of converting the string to the desired type, but also check the format for you and will throw an exception if it is formatted incorrectly. options[:float] 0.0opts.on( -f, float NUM, Float, Convert to float ) do|f|options[:float] fend Some other types that OptionParser can convert to automatically include Time and Integer. Lists of Arguments Arguments can be interpreted as lists. This can be seen as converting to an array, as you converted to Float. While your option string can define the parameter to be called a,b,c, OptionParser will blindly allow any number of elements in the list. So, if you need a specific number of elements, be sure to check the array length yourself. options[:list] []opts.on( -l, list a,b,c, Array, List of parameters ) do|l|options[:list] lend Set of Arguments Sometimes it makes sense to restrict arguments to a switch to a few choices. For example, the following switch will only take a single mandatory parameter, and the parameter must be one of yes, no or maybe. If the parameter is anything else at all, an exception will be thrown. To do this, pass a list of acceptable parameters as symbols after the switch description strings. options[:set] :yesopts.on( -s, set OPT, [:yes, :no, :maybe], Parameters from a set ) do|s|options[:set] send Negated Forms Switches can have a negated form. The switch negated can have one that does the opposite effect, called no-negated. To describe this in the switch description string, place the alternative portion in brackets: [no-]negated. If the first form is encountered, true will be passed to the block, and false will be blocked if the second form is encountered. options[:neg] falseopts.on( -n, [no-]negated, Negated forms ) do|n|options[:neg] nend