Wednesday, March 18, 2020

Using Ruby Environmental Variables

Using Ruby Environmental Variables Environment variables are variables passed to programs by the command line or the graphical shell. When an environment variable is referred to, its value (whatever the variable is defined as) is then referenced. Though there are a number of environment variables that only affect the command line or graphical shell itself (such as PATH or HOME), there are also several that directly affect how Ruby scripts execute. Tip:  Ruby environment variables are similar to ones found in the Windows OS. For example, Windows users may be familiar with a TMP  user variable to define the location of the temporary folder the for the currently logged in user. Accessing Environment Variables from Ruby Ruby has direct access to environment variables via the ENV hash. Environment variables can be directly read or written to by using the index operator with a string argument. Note that writing to environment variables will only have an effect on child processes of the Ruby script. Other invocations of the script will not see the changes in environment variables. #!/usr/bin/env ruby# Print some variablesputs ENV[PATH]puts ENV[EDITOR]# Change a variable then launch a new programENV[EDITOR] geditcheat environment_variables add Passing Environment Variables to Ruby To pass environment variables to Ruby, simply set that environment variable in the shell. This varies slightly between operating systems, but the concepts remain the same. To set an environment variable on the Windows command prompt, use the set command. set TESTvalue To set an environment variable on Linux  or OS X, use the export command. Though  environment variables are a normal part of the Bash shell, only variables that have been exported will be available in programs launched by the Bash shell. $ export TESTvalue Alternatively, if the environment variable will only be used by the program about to be run, you can define any environment variables before the name of the command. The environment variable will be passed onto the program as its run, but not saved. Any further invocations of the program will not have this environment variable set. $ EDITORgedit cheat environment_variables add Environment Variables Used by Ruby There are a number of environment variables that affect how the Ruby interpreter acts. RUBYOPT - Any command-line switches here will be added to any switches specified on the command line.RUBYPATH - When used with the -S switch on the command line, the paths listed in RUBYPATH will be added to the paths searched when looking for Ruby scripts. The paths in RUBYPATH precede the paths listed in PATH.RUBYLIB - The list of paths here will be added to the list of paths Ruby uses to search for libraries included in the program with the require method. The paths in RUBYLIB will be searched before other directories.

Monday, March 2, 2020

The Basics of Aramid Fiber, Polymer Reinforcing Fiber

The Basics of Aramid Fiber, Polymer Reinforcing Fiber Aramid fiber is the generic name of a group of synthetic fibers. The fibers offer a set of properties which make them particularly useful in armor, clothing and a wide range of other applications. The most commonly known commercial brand is Kevlarâ„ ¢, but there others such as Twaronâ„ ¢ and Nomexâ„ ¢ in the same broad family. History Aramids have evolved out of research which stretches back to nylon and polyester. The family is known as aromatic polyamides. Nomex was developed in the early 1960’s and its properties led to wide use in protective clothing, insulation and as a replacement for asbestos. Further research with this meta-aramid led to the fiber we now know as Kevlar. Kevlar and Twaron are para-aramids. Kevlar was developed and trademarked by DuPont and became commercially available in 1973. 2011 worldwide production of Aramids was well over 60,000 tons, and demand is growing steadily as production scales up, costs fall and applications broaden. Properties The chemical structure of the chain molecules is such that the bonds are aligned (for the most part) along the fiber axis, giving them outstanding strength, flexibility and abrasion tolerance. With outstanding resistance to heat and low flammability, they are unusual in that they do not melt – they merely start to degrade (at about 500 degrees Centigrade). They also have very low electrical conductivity making them ideal electrical insulators. With high resistance to organic solvents, the all-around ‘inert’ aspects of these materials offer outstanding versatility for a huge range of applications. The only blot on their horizons is that they are sensitive to UV, acids, and salts. They build static electricity too unless they are specially treated. The outstanding properties which these fibers enjoy provide advantages which make them ideal for a wide range of applications. However, with any composite material, it is important to take care in  handling  and processing. Using gloves, masks, etc. is advisable. Applications Kevlar’s original use was for car tire reinforcement, where the technology still dominates, but in transport, the fibers are used as a replacement for asbestos – for example in brake linings. Probably the most widely known application is in body armor, but other protective uses include fireproof suits for firefighters, helmets, and gloves. Their high strength/weight ratio makes them attractive for use as reinforcing (for example in composite materials particularly where flexing tolerance is important, such as aircraft wings). In construction, we have fiber-reinforced concrete and thermoplastic pipes. Corrosion is a major problem for expensive undersea pipelines in the oil industry, and thermoplastic pipe technology was developed to prolong pipeline life and reduce maintenance costs. Their low stretch properties (typically 3.5% at break), high strength and abrasion resistance make aramid fibers ideal for ropes and cables, and they are even used for mooring ships. In the sporting arena, bowstrings, tennis racquet strings, hockey sticks, skis and running shoes are some of the application areas for these outstanding fibers, with sailors enjoying the benefits of aramid-reinforced hulls, aramid lines and Kevlar wear-patches on their elbows, knees, and rears! Even in the music world aramid fibers are making themselves heard as instrument reeds and drumheads, with the sound being relayed through aramid-fiber loudspeaker cones. The Future New applications are being announced regularly, for example, a high-performance protective coating for harsh environments which embeds Kevlar fibers in an ester. This is ideal for coating new steel pipelines – for example in utilities where water pipes may bury underground and budgets do not permit the more expensive thermoplastic alternatives. With improved epoxies and other resins being introduced on a regular basis and given the continuous scaling up in worldwide production of aramids in many forms (fiber, pulp, powder, chopped fiber and woven mat) the increased use of the material is guaranteed both in its raw form and in composites.