Chit chat

======

The /etc/hosts file does not like non-existant web sites as part of the file. It ignores everything after that part of the entry. Also be sure to clear your cache.

Fell and hurt my hand really bad. Scratched a lot of the rest of my arms and legs.

————————————————-

Need command line access, but the device you are using does not support a command line interface. Answer, set up a server or get access to a server with webmin installed. Then just use the command line interface via webmin.

or Install firessh in a browser.

or set up a jar file on the local machine.

Download the software
http://weavervsworld.com/ssh/mindterm312.jar
or
http://weavervsworld.com/ssh/mindterm312.weavselfsign.jar

Then set up an html file either locally on on a server such as term.html. Then load term.html into your browser.

<html>
<body>
<h4 class=’heading’>Mindterm Applet Information</h4>
<p class=’centererror’><b>Keep this window open after the applet has loaded.</b></p>

</body>
</html>

Note: the jar file should be in the same directory as the html file unless you desinate otherwise in the html file. Usually sandbox the app when run.

 

If you do not want to store the jar file locally you can use:
<html>
<body>
<h4 class=’heading’>Mindterm Applet Information</h4>
<p class=’centererror’>

<b>Keep this window open after the applet has loaded.</b>

</p>
http://weavervsworld.com/ssh/mindterm312.jar’&gt;

</body>
</html>

————————————————-

Base64 decoder. Use at your own risk.

From wikipedia:The  term “Base64″ refers to a specific MIME content transfer encoding. It is also used as a generic term for any similar encoding scheme that encodes binary data by treating it numerically and translating it into a base 64 representation. The particular choice of base is due to the history of character set encoding: one can choose 64 characters that are both part of the subset common to most encodings, and also printable. This combination leaves the data unlikely to be modified in transit through systems, such as email, which were traditionally not 8-bit clean. The precise choice of characters is difficult. The earliest instances of this type of encoding were created for dialup communication between systems running the same OS – e.g. Uuencode for UNIX, BinHex for the TRS-80 (later adapted for the Macintosh) – and could therefore make more assumptions about what characters were safe to use. For instance, Uuencode uses uppercase letters, digits, and many punctuation characters, but no lowercase, since UNIX was sometimes used with terminals that did not support distinct letter case. Unfortunately for interoperability with non-UNIX systems, some of the punctuation characters do not exist in other traditional character sets. The MIME Base64 encoding replaces most of the punctuation characters with the lowercase letters, a reasonable requirement by the time it was designed. MIME Base64 uses A–Z, a–z, and 0–9 for the first 62 digits. There are other similar systems, usually derived from Base64, that share this property but differ in the symbols chosen for the last two digits; an example is UTF-7.


 The code below shows the function declaration and how to use it.And you can see online
demo at here(you can right click to see all source)

<html>
  <head>
     <title>base64 Encoding/Decoding</title>
  </head>

  <script type="text/javascript">
  <!--

  var keyStr = "ABCDEFGHIJKLMNOP" +
               "QRSTUVWXYZabcdef" +
               "ghijklmnopqrstuv" +
               "wxyz0123456789+/" +
               "=";

  function encode64(input) {
     input = escape(input);
     var output = "";
     var chr1, chr2, chr3 = "";
     var enc1, enc2, enc3, enc4 = "";
     var i = 0;

     do {
        chr1 = input.charCodeAt(i++);
        chr2 = input.charCodeAt(i++);
        chr3 = input.charCodeAt(i++);

        enc1 = chr1 >> 2;
        enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
        enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
        enc4 = chr3 & 63;

        if (isNaN(chr2)) {
           enc3 = enc4 = 64;
        } else if (isNaN(chr3)) {
           enc4 = 64;
        }

        output = output +
           keyStr.charAt(enc1) +
           keyStr.charAt(enc2) +
           keyStr.charAt(enc3) +
           keyStr.charAt(enc4);
        chr1 = chr2 = chr3 = "";
        enc1 = enc2 = enc3 = enc4 = "";
     } while (i < input.length);

     return output;
  }

  function decode64(input) {
     var output = "";
     var chr1, chr2, chr3 = "";
     var enc1, enc2, enc3, enc4 = "";
     var i = 0;

     // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
     var base64test = /[^A-Za-z0-9\+\/\=]/g;
     if (base64test.exec(input)) {
        alert("There were invalid base64 characters in the input text.\n" +
              "Valid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\n" +
              "Expect errors in decoding.");
     }
     input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

     do {
        enc1 = keyStr.indexOf(input.charAt(i++));
        enc2 = keyStr.indexOf(input.charAt(i++));
        enc3 = keyStr.indexOf(input.charAt(i++));
        enc4 = keyStr.indexOf(input.charAt(i++));

        chr1 = (enc1 << 2) | (enc2 >> 4);
        chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
        chr3 = ((enc3 & 3) << 6) | enc4;

        output = output + String.fromCharCode(chr1);

        if (enc3 != 64) {
           output = output + String.fromCharCode(chr2);
        }
        if (enc4 != 64) {
           output = output + String.fromCharCode(chr3);
        }

        chr1 = chr2 = chr3 = "";
        enc1 = enc2 = enc3 = enc4 = "";

     } while (i < input.length);

     return unescape(output);
  }

  //--></script>

  <body>

     <form name="base64Form">

        Type in the message you want to encode in base64, or paste<br>
        base64 encoded text into the text field, select Encode or Decode, <br>
        and click the button!<br>

        <textarea name="theText" cols="40" rows="6"></textarea><br>

        <input type="button" name="encode" value="Encode to base64"
           onClick="document.base64Form.theText.value=encode64(document.base64Form.theText.value);">

        <input type="button" name="decode" value="Decode from base64"
           onClick="document.base64Form.theText.value=decode64(document.base64Form.theText.value);">

     </form>

  </body>
</html>

————————————————-

There are two ways to do this either make a sort of tapestry or convert them into a rotating pictures in a .gif file.

Take the following pictures:

 

 

 

Can be converted into one picture with:

$ montage *.jpg bread.png

Or they can be converted to rotating pictures with: (note: you may need to resize the pictures first to the same dimensions)

$ convert *.jpg bread.gif

More information at: http://www.imagemagick.org/

————————————————-

It’s almost the holiday season and you might want to get geekie. If you are unsure about this, get profession help for the project. Try this at your own risk. We take no responsibilities for anything you may or may not do. This article is not a how to, but it is informational.

What we want to do is to control lighting so that we can turn it off or on with electronic equipment instead of doing it manually with a traditional light switch.

In this case, we may want to control holiday lights Such as an Xmas tree.

We could use the light switch like above, or we can use a computer or a micro-controller. In this case we will suggest three posiblilities. The computer using a
traditional parallel port, A raspberry Pi, or an Arduino.

The simplest way to do this is with a solid state relay. Basically it is just like turning on an led.

If you turn on the data line so it goes to near 5 volts, the led will turn on  or the SSR will allow the output side to work. An SSR let you control the switch but the low voltage circuit when hooked up correctly will be isolated from the circuit being controlled.

When the SSR is controlled electronically, we can program how the lights will come on or go off.

Parallel port: using a breakout cable

 

 

 

Code:

In FreeBasic we would use:

out 888, (2^0) or out 888, 1
to turn on the Led and
out 888, 0
to turn off the led.

Raspberry Pi: (Raspberry Pi ver, B will be different also). Note: normally the resistor and the led would be in opposite positions.

Code:

Oldest version
-----------
# Turn light on
cd /sys/class/gpio
# Turn on pin but defaults to low.
echo 17 > export
# Set port direction in this case we aredoing output.
echo out > gpio17/direction
# Set pin high and turn on led.
echo 1 > gpio17/value
#Turn light off
echo 0 > gpio17/value
-----------------------------------
Newer version: You have to use the full path with commands.
# Turn light on
cd /sys/class/gpio
# Turn on pin but defaults to low.
echo "17" > /sys/class/gpio/export
# Set port direction in this case we aredoing output.
echo "out" > /sys/class/gpio/gpio17/direction
# Set pin high and turn on led.
echo "1" > /sys/class/gpio/gpio17/value
#Turn light off
echo "0" > /sys/class/gpio/gpio17/value

Arduino:


 


Code:

/*
 * Blink
 *
 * The basic Arduino example.  Turns on an LED on for one second,
 * then off for one second, and so on...  We use pin 13 because,
 * depending on your Arduino board, it has either a built-in LED
 * or a built-in resistor so that you need only an LED.
 *
 * http://www.arduino.cc/en/Tutorial/Blink
 */

int ledPin = 13;                // LED connected to digital pin 13

void setup()                    // run once, when the sketch starts
{
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
}

void loop()                     // run over and over again
{
  digitalWrite(ledPin, HIGH);   // sets the LED on
  delay(1000);                  // waits for a second
  digitalWrite(ledPin, LOW);    // sets the LED off
  delay(1000);                  // waits for a second
}

So you could use the same resistor and led combination for all three devices.
So once you have done it for one, you can easily do it for the others! If you
want to control several leds, it gets fun like the video above,
Beaglebone Black.

 


Code:

var b = require('bonescript');
var led = "P8_13";
var state = 0;

b.pinMode(led, 'out');
toggleLED = function() {
    state = state ? 0 : 1;
    b.digitalWrite(led, state);
};

timer = setInterval(toggleLED, 100);

stopTimer = function() {
    clearInterval(timer);
};

setTimeout(stopTimer, 30000);

————————————————-

Source: helloworld.java

import java.io.*;
class helloworld
{
public static void main(String args[ ])
{
/* Display text on the screen */
System.out.println(“Hello World!”);
}
}

Compile:

$ javac helloworld.java

Run

$ java helloworld
Hello World!

Create a jar file: (general executable)

$ jar cvfe helloworld.jar helloworld helloworld.class
added manifest
adding: helloworld.class(in = 426) (out= 291)(deflated 31%)

Run it.

$ java -jar helloworld.jar
Hello World!

————————————————-

Apache users note:

You probably updated your Ubuntu installation and one of the updates included the upgrade of Apache to version 2.4.x

In Apache 2.4.x the vhost configuration files, located in the /etc/apache2/sites-available directory, must have the .conf extension.

For instance, in the sites-available and the sites-enabled directories, files now seem to have to have a .conf extension. If you already have many virtual hosts setup, this can be a challenge. some people suggest a simple move (mv) to change the filenames, but then the links in sites-enabled will not be correct. You will need to remove the old links and establish new ones. A simple batch file can be created to accomplish the job.

In the sites-available directory

$ sudo mv http://www.yoursite.com http://www.yoursite.com.conf.

In the sites-enabled directory

$ sudo unlink http://www.yoursite.com
$ sudo ls -s ../sites-available/www.yoursite.conf.

Then you may need to rerun a2ensite on each site.

Also could be a change in the default virtual host directory:

Default Virtual Host

If your Apache configuration file is replaced during the upgrade, the location of your default virtual host will change from /var/www to /var/www/html. You may have to disable the default virtual host again, if you don’t want it. We have a specific directory identified in the .conf file to get around this.

Headless web server still seems to work. Arrow is pointing the the leds connected to the parallel port. The leds can do light demos or even present messages about the server status.

—————————————

Starting Linux Screen

Screen is started from the command line just like any other command: [root@office ~]# screen
Note: you do not have to be root to use it and good security suggests you only use root as a last resort.

You are now inside of a window within screen. This functions just like a normal shell except for a few special characters.
Control Command

Command: “Ctrl-a”

Screen uses the command “Ctrl-a” that’s the control key and a lowercase “a” as a signal to send commands to screen instead of the shell.

For example, “Ctrl-a” then “?”.

 

Key bindings are the commands the screen accepts after you hit “Ctrl-a”. You can reconfigure these keys to your liking using a .screenrc file, but I just use the defaults.
Creating Windows

Command: “Ctrl-a” “c”.

To create a new window, you just use “Ctrl-a” “c”.

This will create a new window for you with your default prompt. Your old window is still active.

For example, I can be running top and then open a new window to do other things. Top stays running! It is still there. To try this for yourself, start up screen and then run top.

Now open a new window with: “Ctrl-a” “c”

Your top window is still running you just have to switch back to it.
Switching Between Windows

Command: “Ctrl-a” “n”

Screen allows you to move forward and back. In the example above, you could use “Ctrl-a “n” to get back to top. This command switches you to the next window.

The windows work like a carousel and will loop back around to your first window.

You can create several windows and toggle through them with “Ctrl-a” “n” for the next window or “Ctrl-a” “p” for the previous window.

Each process will keep running until you kill that window.
Detaching From Screen

Command: “Ctrl-a” “d”

Detaching is the most powerful part of screen. Screen allows you to detach from a window and reattach later. If your network connection fails, screen will automatically detach your session! Note this is great when you have run screen on another system and you have to get away or to shut your system down without bothering the system you were attached to.

You can detach from the window using “Ctrl-a” “d”.

This will drop you into your shell.

All screen windows are still there and you can re-attach to them later.

This is great when you are using rsync for server migration.

Reattach to Screen

If your connection drops or you have detached from a screen, you can re-attach by just running:

$ screen -r

This will re-attach to your screen.

However, if you have multiple screens you may get this:

If you get this, just specify the screen you want.

$ screen -r   27153.pts-11.oelt02

Logging Your Screen Output

As a consultant, I find it important to keep track of what I do to someone’s server. Fortunately, screen makes this easy.

Using “Ctrl-a” “H”, creates a running log of the session.

Screen will keep appending data to the file through multiple sessions. Using the log function is very useful for capturing what you have done, especially if you are making a lot of changes. If something goes awry, you can look back through your logs.

Getting Alerts

Screen can monitor a window for activity or inactivity. This is great if you are downloading large files, compiling, or waiting for output.

If you are waiting for output from a long running program, you can use “Ctrl-a” “M” to look for activity. Screen will then flash an alert at the bottom of the page when output is registered on that screen.

I use this when running a command that takes a long time to return data. I can just fire up the command, switch to another window and not have to keep switching back to check the status.

You can also monitor for inactivity. Why use this?

If you are downloading a large file or compiling a program, you can be notified when there is no more output. This is a great signal to when that job is done. To monitor for silence or no output use “Ctrl-A” “_”.
Locking Your Screen Session

If you need to step away from your computer for a minute, you can lock your screen session using “Ctrl-a” “x”. This will require a password to access the session again.

Stopping Screen

When you are done with your work, I recommend you stop the session instead of saving it for later. To stop screen you can usually just type exit from your shell. This will close that screen window. You have to close all screen windows to terminate the session.

You should get a message about screen being terminated once you close all windows. [screen is terminating]

Alternatively, you can use “Ctrl-a” “k”. You should get a message if you want to kill the screen.

—————————————-

Raisin Bread

FNVOY92GXL5P4AO.MEDIUM

Good day.

Advertisements