Welcome, Guest. Please login or register.

Author Topic: What did you learn today?  (Read 208778 times)

0 Members and 9 Guests are viewing this topic.

Online Max Wedge

  • Contributor
  • Member
  • Location: The thumb in Reg 4
  • Posts: 5570
  • Engineering Pathologist
  • Motorcycles: '10 R1200GS
Re: What did you learn today?
« Reply #1550 on: April 03, 2019, 12:58:04 PM »
Since bumpers are tied to the frame, check that s*** out too.

I've been under it and looks okay, but the hitch is like part of the rear spring hangar, which I found odd.
You never see a motorcycle parked outside a psychiatrists' office.
Where am I?

Online sodapop6620

  • Member
  • Location: SEPA
  • Posts: 1255
  • Motorcycles: 4
Re: What did you learn today?
« Reply #1551 on: April 04, 2019, 07:16:44 PM »
Spring has a Black Friday. I heard it on TV today but I am not sure which Friday it is.

Online Skee

  • Contributor
  • Member
  • Location: SE PA
  • Posts: 1688
  • Motorcycles: 2019 Versys
Re: What did you learn today?
« Reply #1552 on: April 05, 2019, 07:41:40 AM »
Spring has a Black Friday. I heard it on TV today but I am not sure which Friday it is.

Maybe today. It’s friday, black overcast and raining again
The fishermen know that the sea is dangerous and the storm terrible,
but they have never found these dangers sufficient reason for remaining ashore.   Vincent van Gogh

Offline Baxter

  • Member
  • Location: Bismarck, North Dakota
  • Posts: 59
  • Motorcycles: Soon to be a classic First Generation Ninja 650R
Re: What did you learn today?
« Reply #1553 on: April 06, 2019, 07:51:54 PM »
The garage at the soon-to-be new house has two plain screw in light fixtures.  The present owner has what appears to be 65 watt floods installed.  I would like better light for the occasional workday, and my wife wants better light just because she likes bright light. 

So I discovered some led fixtures at the local big box store (Menards) that put out the equivalent lumens of about 3 100-watt incandescent bulbs in a flat panel of 1 foot by 4 feet by 1 inch deep, in a simple white panel design.  I might just go with this, as we both like the clean design and the light should be plentiful.  https://www.menards.com/main/lighting-ceiling-fans/indoor-lighting/work-shop-lights/patriot-lighting-reg-4300-lumens-1-x-4-led-flat-panel-light/v1842/p-1523341856351.htm

I'm thinking that they can be surface mounted where the existing boxes are located, and positioned to be spread wide in the two-car garage.  Any other thoughts?  I was also looking at these:  https://www.amazon.com/Motion-Activated-Ceiling-Packing-Daylight/dp/B07GSTFMDZ.  They seem a bit too sci-fi, but if they actually work, they might be ok.
I broke the internet!

Online Bounce

  • Contributor
  • Member
  • Location: USA
  • Posts: 3150
    • FJR-Tips
  • Motorcycles: Yes
Re: What did you learn today?
« Reply #1554 on: April 07, 2019, 10:40:54 AM »
We put up something similar (at little more design-ish). It's the dimensions you mentioned. We installed it (surface mounted) in the kitchen. Talk about bright!

visitors can't see pics , please register or login

Online HipGnosis

  • Member
  • Location: Between home and the horizon
  • Posts: 1592
  • It's Hip, ya know
  • Motorcycles: F800ST(low), VStar 950, Ninja 650
Re: What did you learn today?
« Reply #1555 on: April 07, 2019, 10:49:28 AM »
The garage at the soon-to-be new house has two plain screw in light fixtures.
...
I was also looking at these:  https://www.amazon.com/Motion-Activated-Ceiling-Packing-Daylight/dp/B07GSTFMDZ.  They seem a bit too sci-fi, but if they actually work, they might be ok.
The '80W / 8000 lumens' doesn't add up.  Google says 'a 100-watt incandescent bulb gives about 1600 lumens.'
I like motion lights, but I wouldn't put a bright one(s) in the garage.  I don't want that much light in my face when pulling into the garage at night.
Life is made up of moments, small pieces of glittering mica in a long stretch of gray cement. We have to teach ourselves how to make room for them, to love them, and to live, really live. - Anna Quindlen

Offline Baxter

  • Member
  • Location: Bismarck, North Dakota
  • Posts: 59
  • Motorcycles: Soon to be a classic First Generation Ninja 650R
Re: What did you learn today?
« Reply #1556 on: April 07, 2019, 11:53:08 AM »
We put up something similar (at little more design-ish). It's the dimensions you mentioned. We installed it (surface mounted) in the kitchen. Talk about bright!

visitors can't see pics , please register or login


Thanks, is yours led? I'm thinking that's better than using cold-start florescent lighting.
I broke the internet!

Offline Baxter

  • Member
  • Location: Bismarck, North Dakota
  • Posts: 59
  • Motorcycles: Soon to be a classic First Generation Ninja 650R
Re: What did you learn today?
« Reply #1557 on: April 07, 2019, 12:04:04 PM »
The garage at the soon-to-be new house has two plain screw in light fixtures.
...
I was also looking at these:  https://www.amazon.com/Motion-Activated-Ceiling-Packing-Daylight/dp/B07GSTFMDZ.  They seem a bit too sci-fi, but if they actually work, they might be ok.
The '80W / 8000 lumens' doesn't add up.  Google says 'a 100-watt incandescent bulb gives about 1600 lumens.'
I like motion lights, but I wouldn't put a bright one(s) in the garage.  I don't want that much light in my face when pulling into the garage at night.

Thanks.  I have some reservations about this design  There seems to be several different variations on this theme, some with more or less lumens, some with and without motion sensing.  I probably don't need 8000 lumens in one place--having all that light emitted from just one spot, as opposed to being spread out in a panel, may just make a glare rather than provide useful light.  So a less bright version may better suit my purpose.  I'm also concerned that most don't seem to have UL certification. 

In addition to these and the panel design, there's also screw in "bulbs" shaped in a vertical cylinder with led's in rows like corn kernels on the outside. I've also thought that they might produce a lot of glare.

But I'm mostly thinking that an led light source will be better than even a cold-start florescent. 
I broke the internet!

Online HipGnosis

  • Member
  • Location: Between home and the horizon
  • Posts: 1592
  • It's Hip, ya know
  • Motorcycles: F800ST(low), VStar 950, Ninja 650
Re: What did you learn today?
« Reply #1558 on: April 12, 2019, 11:01:20 AM »
Some people need to learn things the hard way.
Apparently I need to re-learn things the hard way.

I'm going to repaint the F800ST I got last fall. 
I'm painting the headlight shell of my VStar 950 first (for practice).  It is cracked from skidding into a brand new jeep in a wet traffic circle... (they needed to learn to NOT stop IN a traffic circle)

I re-learned that you need to put bondo on in thin layers.
AND, I re-learned that (at least when you don't do that) you need to change the sand paper every so often to be productive.
Life is made up of moments, small pieces of glittering mica in a long stretch of gray cement. We have to teach ourselves how to make room for them, to love them, and to live, really live. - Anna Quindlen

Online HipGnosis

  • Member
  • Location: Between home and the horizon
  • Posts: 1592
  • It's Hip, ya know
  • Motorcycles: F800ST(low), VStar 950, Ninja 650
Re: What did you learn today?
« Reply #1559 on: April 18, 2019, 02:23:56 PM »
High heels were invented for butchers in ancient Egypt, to raise them up from the bloody floors.
Life is made up of moments, small pieces of glittering mica in a long stretch of gray cement. We have to teach ourselves how to make room for them, to love them, and to live, really live. - Anna Quindlen

Offline garry

  • Member
  • Location: Pittsburgh, PA
  • Posts: 1020
  • Bleeds Orange...
    • MotoRoads
Re: What did you learn today?
« Reply #1560 on: April 19, 2019, 01:57:23 PM »
I learned that the .NET XmlDocument class saves XML files it can't load. WTFF?

Evidently Microsoft requires you to leave off the XML declaration line at the start of the file if you want to use UTF-8. WTFF?
2009 KTM 570 EXC
2017 KTM Super Duke GT

Online chornbe

  • Contributor
  • Member
  • Location: Wilmington, Delaware
  • Posts: 5989
  • Burdened with glorious purpose.
    • The Pace Motorcycle Podcast
  • Motorcycles: The one I'm borrowing
Re: What did you learn today?
« Reply #1561 on: April 19, 2019, 03:04:36 PM »
I learned that the .NET XmlDocument class saves XML files it can't load. WTFF?

Evidently Microsoft requires you to leave off the XML declaration line at the start of the file if you want to use UTF-8. WTFF?

Yeeeeeup. Learned that the hard way.

On the upside, once you get that silliness out of they way, it is an EXCELLENT class to subclass and create custom methods on for storing key-value pair data. Works a charm for config files.

Here's my subclass from an old project. Considerably more verbose than it *really* needs to be as it's been made pretty generic. FieldValue(...) and SetFieldValue(...) are the important methods here.

Code: [Select]
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Xml;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using fwfwif;
using System.Data.Common;
using System.Data;

namespace FWFWLib {
   
    [Serializable]
    public class DataDocument : XmlDocument, IDisposable, ISerializable, fwfwif.IDataDocument {

        #region class level members and consts
        /// <summary>
        /// XPath to the interally stored key-value pair structure
        /// </summary>
        protected readonly string XPATH_FIELDS = "/$DOCTYPE$/fields";
       
        /// <summary>
        /// Modified xpath used to fetch data from a structured node
        /// </summary>
        protected readonly string XPATH_SINGLE_FIELD = "/$DOCTYPE$/fields/$FIELD_NAME$";

        protected readonly string XPATH_FIELD_NAMES = "/$DOCTYPE$/fields/*";

        /// <summary>
        /// convenience object to provide easy access to the DocumentElement as a root object
        /// </summary>
        protected XmlElement root = null;

        /// <summary>
        /// flag indicating if the message has been archived. This is useful if the DataDocument makes many hops from handler to handler and only needs to be archived one time.
        /// </summary>
        protected bool archived = false;
        #endregion

        #region startup and teardown
        /// <summary>
        /// public interface to the IDisposable interface. Cleans up resources. Subclasses should always call base.Dispose() if they override Dispose()
        /// </summary>
        public virtual void Dispose() {
            root = null;
        }

        /// <summary>
        /// constructor. Builds a basic DataDocument with no extended data structure. This is a basic starting point for messages that will hold arbitrary data.
        /// </summary>
        public DataDocument() {
            root = this.CreateElement( this.GetType().Name.ToLower() );
            XPATH_FIELDS = XPATH_FIELDS.Replace( "$DOCTYPE$", this.GetType().Name.ToLower() );
            XPATH_SINGLE_FIELD = XPATH_SINGLE_FIELD.Replace( "$DOCTYPE$", this.GetType().Name.ToLower() );
            XPATH_FIELD_NAMES = XPATH_FIELD_NAMES.Replace( "$DOCTYPE$", this.GetType().Name.ToLower() );
            this.AppendChild( root );
            //XmlElement idnode = this.CreateElement( "id" );
            //idnode.InnerText = idValue;
            //root.AppendChild( idnode );
            SetFieldValue( "createtime", DateTime.Now.ToString( "yyyyMMdd HHmmss" ) );
            SetFieldValue( FIELD_ID, System.Guid.NewGuid().ToString() );
        }
        #endregion

        #region class level file info stuffz
        /// <summary>
        /// internal field name to store file data - file size
        /// </summary>
        public const string FIELD_FILE_SIZE = "_filesize";
        /// <summary>
        /// internal field name to store file data - last write time
        /// </summary>
        public const string FIELD_FILE_LAST_UPDATE_TIME = "_lastwritetime";
        /// <summary>
        /// internal field name to store file data - last access time
        /// </summary>
        public const string FIELD_FILE_LAST_ACCESS_TIME = "_lastaccesstime";
        /// <summary>
        /// internal field name to store file data - creation time
        /// </summary>
        public const string FIELD_FILE_CREATION_TIME = "_creationtime";
        /// <summary>
        /// internal field name to store file data - original filename on disc
        /// </summary>
        public const string FIELD_FILE_NAME = "_filename";
        /// <summary>
        /// internal field name to store file data - original full path and filename on disc
        /// </summary>
        public const string FIELD_FILE_FULLNAME = "_fullname";
        /// <summary>
        /// internal field name to store file data - serialized file data (B64)
        /// </summary>
        public const string FIELD_FILE_DATA = "_filedata";
        /// <summary>
        /// structured date format for use in storing the various file dates
        /// </summary>
        public const string DT_FORMAT = "MM/dd/yyyy HH:mm:ss";

        public const string FIELD_ID = "_id";

        #endregion

        #region serialization (which is a joke because the internal structure is XML so... duh!)
        /// <summary>
        /// emits Xml representing the data structure of the MessageObject. Since the MessageObject internally stores data as Xml this is a very simple function. It is provided in case the internal data structure every changes to a containment other than Xml.
        /// </summary>
        /// <returns>Xml representing the MessageObject instance</returns>
        public virtual string ToXml() {
            return this.OuterXml;
        }

        /// <summary>
        /// emits text (Xml) representing the data structure of the MessageObject.
        /// </summary>
        /// <returns>text representing the MessageObject instance</returns>
        public override string ToString() {
            return this.OuterXml;
        }

        #region convenience features. Ya know... electric windows, cruise control, leather... the works.

        public string ID {
            get {
                return FieldValue( FIELD_ID );
            }
        }

        /// <summary>
        /// Accessor to the Archived flag. Where this is useful is when the MessageObject passes through many handlers (and even servers!) but only needs to be archived a single time. The first code to touch the MessageObject instance can set Archived to :true: and other handlers can skip archiving the message (default function), thereby reducing redundant data.
        /// </summary>
        public bool Archived {
            get {
                return archived;
            }
            set {
                archived = value;
            }
        }

        /// <summary>
        /// Convenience accessor with Boolean wrapper into the named field
        /// </summary>
        /// <param name="flagname">field name within the message object</param>
        /// <returns>true if field value is a known "yes" or "true" value, false otherwise</returns>
        public bool Flag( string flagname ) {
            bool rtn = false;

            string val = FieldValue( flagname );
            try {
                rtn = bool.Parse( val );
            } catch( Exception ) {
                try {
                    val = val.Trim().ToLower();
                    if( "yes" == val || "y" == val
                        || "1" == val || "true" == val || "-1" == val
                        || "correct" == val || "affirmative" == val ) {
                        rtn = true;
                    }
                } catch( Exception ) { }
            }

            return rtn;
        }

        /// <summary>
        /// Sets the named field to a value of "true" or "false"
        /// </summary>
        /// <param name="flagname">field name within the message object</param>
        /// <param name="value">boolean true or false, stored internally as string representation bool.ToString()</param>
        public void SetFlag( string flagname, bool value ) {
            SetFieldValue( flagname, value.ToString() );
        }

        /// <summary>
        /// Accessor to the list of field names within the internal data structure
        /// </summary>
        public virtual string[] FieldNames {
            get {
                List<string> flds = new List<string>();
                XmlNodeList fields = root.SelectNodes( XPATH_FIELD_NAMES );
                foreach( XmlNode node in fields ) {
                    flds.Add( node.Name );
                }
                return flds.ToArray();
            }
        }

        public DataSet DataSet {
            get {
                DataSet rtn = new DataSet();

                string xml = FieldValue( "ds_payload_xml " );
                string schema = FieldValue( "ds_payload_schema" );

                try { // failure is ok because these might not be set - valid
                    rtn = new DataSet();
                    rtn.ReadXmlSchema( new StringReader( schema ) );
                    rtn.ReadXml( new StringReader( xml ) );
                } catch( Exception ) { }

                return rtn;
            }
            set {
                if( null != value ) {
                    System.Text.StringBuilder sbXml = new System.Text.StringBuilder();
                    TextWriter swXml = new StringWriter( sbXml );
                    value.WriteXml( swXml );
                    swXml.Close();
                    swXml.Dispose();

                    System.Text.StringBuilder sbSch = new System.Text.StringBuilder();
                    TextWriter swSch = new StringWriter( sbSch );
                    value.WriteXmlSchema( swSch );
                    swSch.Close();
                    swSch.Dispose();

                    SetFieldValue( "ds_payload_schema", sbSch.ToString() );
                    SetFieldValue( "ds_payload_xml", sbXml.ToString() );
                }
            }
        }
        #endregion

        #region file attachment io
        /// <summary>
        /// encapsulates the named file. Sets the internal fields to represent the file data, Base64 encodes the file data and stores it in _filedata field
        /// </summary>
        /// <param name="filename">name of the file on disc to incapsulate</param>
        public void AttachFile( string filename ) {
            if( !File.Exists( filename ) ) {
                throw new InvalidOperationException( "File is not present or path to file is invalid" );
            }
            FileInfo file = new FileInfo( filename );

            SetFieldValue( FIELD_FILE_SIZE, file.Length );
            SetFieldValue( FIELD_FILE_LAST_ACCESS_TIME, file.LastAccessTime.ToString( DT_FORMAT ) );
            SetFieldValue( FIELD_FILE_LAST_UPDATE_TIME, file.LastWriteTime.ToString( DT_FORMAT ) );
            SetFieldValue( FIELD_FILE_CREATION_TIME, file.CreationTime.ToString( DT_FORMAT ) );
            SetFieldValue( FIELD_FILE_NAME, file.Name );
            SetFieldValue( FIELD_FILE_FULLNAME, file.FullName );

            byte[] fileData = Utils.ReadFileToBytes( file.FullName );
            //string b64 = System.Text.Encoding.ASCII.GetString( fileData );
            string b64 = System.Convert.ToBase64String( fileData );
            SetFieldValue( FIELD_FILE_DATA, b64 );

        }

        /// <summary>
        /// read accessor to the underlying file data as native byte array
        /// </summary>
        public byte[] FileData {
            get {
                byte[] rtn = { };
                string b64 = FieldValue( FIELD_FILE_DATA );
                if( null != b64 && "" != b64 ) {
                    rtn = System.Convert.FromBase64String( b64 );
                }
                return rtn;
            }
        }
        /// <summary>
        /// read accessor to the underlying file data as Base64 encoded text
        /// </summary>
        public string FileDataAsB64 {
            get {
                //return System.Convert.ToBase64String( FileData );
                return FieldValue( FIELD_FILE_DATA );
            }
        }

        /// <summary>
        /// read accessor to the filename information
        /// </summary>
        public string Filename {
            get {
                string rtn = "";
                rtn = FieldValue( FIELD_FILE_NAME );
                return rtn;
            }
        }

        /// <summary>
        /// read accessor to the full filespec of the represented file
        /// </summary>
        public string FullFilename {
            get {
                string rtn = "";
                rtn = FieldValue( FIELD_FILE_FULLNAME );
                return rtn;
            }
        }

        /// <summary>
        /// read accessor to the file size
        /// </summary>
        public int FileSize {
            get {
                int size = 0;
                try { size = int.Parse( FieldValue( FIELD_FILE_SIZE ) ); } catch( Exception ) { }
                return size;
            }
        }

        /// <summary>
        /// read accessor to the last update time of the underlying file
        /// </summary>
        public DateTime LastUpdateTime {
            get {
                DateTime rtn = DateTime.Parse( "1980 Jan 01" );
                try {
                    rtn = DateTime.ParseExact(
                        FieldValue( FIELD_FILE_LAST_UPDATE_TIME ), DT_FORMAT,
                        new System.Globalization.DateTimeFormatInfo()
                    );
                } catch( Exception ) { }
                return rtn;
            }
        }

        /// <summary>
        /// read accessor to the last accessed time of the underlying file
        /// </summary>
        public DateTime LastAccessTime {
            get {
                DateTime rtn = DateTime.Parse( "1980 Jan 01" );
                try {
                    rtn = DateTime.ParseExact(
                        FieldValue( FIELD_FILE_LAST_ACCESS_TIME ), DT_FORMAT,
                        new System.Globalization.DateTimeFormatInfo()
                    );
                } catch( Exception ) { }
                return rtn;
            }
        }

        /// <summary>
        /// read accessor to the file creation time of the underlying file
        /// </summary>
        public DateTime CreationTime {
            get {
                DateTime rtn = DateTime.Parse( "1980 Jan 01" );
                try {
                    rtn = DateTime.ParseExact(
                        FieldValue( FIELD_FILE_CREATION_TIME ), DT_FORMAT,
                        new System.Globalization.DateTimeFormatInfo()
                    );
                } catch( Exception ) { }
                return rtn;
            }
        }

        /// <summary>
        /// writes the encapsulated file data to the named file and applicable file attributes
        /// </summary>
        /// <param name="filename">name of the file on disc to create and update</param>
        public void WriteFileData( string filename ) {
            Stream strm = new FileStream( filename, FileMode.Create, FileAccess.Write, FileShare.None );
            WriteFileData( strm );
            strm.Close();
            strm.Dispose();
        }
        /// <summary>
        /// writes the encapsulated file data to the provided Stream object
        /// </summary>
        /// <param name="strm">raw Stream object</param>
        public void WriteFileData( Stream strm ) {
            if( null != strm ) {
                byte[] bytes = this.FileData;
                strm.Write( bytes, 0, bytes.Length );
            }
        }

        #endregion

        #region fieldvalue as string
        /// <summary>
        /// Accessor to set the value of a named field. If the named field does not exist and the FixedList value is false (default), the field will be created. Throws an exception if the FixedList value is true and the field does not exist.
        /// </summary>
        /// <param name="fieldname">name of the field to create or modify</param>
        /// <param name="val">value with which to update the named field</param>
        public void SetFieldValue( string fieldname, object val ) {
            XmlNode fields = this.DocumentElement.SelectSingleNode( XPATH_FIELDS );
            if( null == fields ) {
                fields = this.CreateElement( "fields" );
            } else {
                this.DocumentElement.RemoveChild( fields );
            }

            XmlNode node = fields.SelectSingleNode( fieldname );
            if( null != node ) {
                fields.RemoveChild( node );
                if( null != val ) {
                    node.InnerText = val.ToString();
                }
            } else {
                node = this.CreateElement( fieldname );
                if( null != val ) {
                    node.InnerText = val.ToString();
                }
            }
            if( null != fields && null != node ) {
                fields.AppendChild( node );
            }
            this.DocumentElement.AppendChild( fields );
        }

        /// <summary>
        /// Accessor to retrieve the value of the named field. If the named field does not exist and the FixedList value is false (default), the function returns an empty string. Throws an exception if the FixedList value is true and the field does not exist.
        /// </summary>
        /// <param name="fieldname">name of the field to retrieve</param>
        /// <returns>string value of the named field. throws exception if the field does not exist and FixedList is :true:</returns>
        public string FieldValue( string fieldname ) {
            string rtn = "";
            XmlNode node = this.SelectSingleNode( XPATH_SINGLE_FIELD.Replace( "$FIELD_NAME$", fieldname ) );
            if( null != node ) {
                rtn = node.InnerText;
            }
            return rtn;
        }
        #endregion

        public virtual string ToText(){
            string rtn = "";
            foreach( string fieldName in this.FieldNames ){
                rtn += fieldName + ":" + FieldValue( fieldName ) + "\n";
            }
            return rtn;
        }

    }

}

Side note: I really, really like working in Swift for iOS. A lot. But holy crap, the years, and years, and years I spent making some really special magic with C# and .NET... I miss working in that quite a bit.
this signature on hold pending review

Online Bounce

  • Contributor
  • Member
  • Location: USA
  • Posts: 3150
    • FJR-Tips
  • Motorcycles: Yes
Re: What did you learn today?
« Reply #1562 on: April 19, 2019, 09:47:54 PM »
I found that time flies out in the shop when busy doing stuff.