Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
jesus WEP
Oct 17, 2004


hobbesmaster posted:

give us a sample of questions... were they like "why are p-langs pieces of poo poo?"
i've had to stop myself yosposting in SO comments a few times lol

oh man this was the worst snipe, content

i got downvoted to hell on there for saying that oracle join syntax is a POS

Adbot
ADBOT LOVES YOU

Bloody
Mar 3, 2013

why would you ever post on so

jesus WEP
Oct 17, 2004


Bloody posted:

why would you ever post on so

sa is blocked at work

Zaxxon
Feb 14, 2004

Wir Tanzen Mekanik

Bloody posted:

why would you ever post on so

gotta get that sweet posting high.

qntm
Jun 17, 2009
I use SO as a passive-aggressive outlet for my hatred of most programming things

"why does X behave in this confusing, dumb way? oh, because it's stupid and bad, okay"

Luigi Thirty
Apr 30, 2006

Emergency confection port.

It turns out drawing a horizontal line of pixels in a 1bpp graphics mode is faster if you do it in groups of 1 byte and then figure out how many are left over at the end instead of doing it one pixel at a time :doh:

JawnV6
Jul 4, 2004

So hot ...
hi, im putting things in a text file for humans to read

it sure would be nice if i could color the text, there's some common strings that would be very nice to highlight

is there a way to spit out a .rtf or something programmatically that's not as awful as dealing with console color codes?

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.

JawnV6 posted:

hi, im putting things in a text file for humans to read

it sure would be nice if i could color the text, there's some common strings that would be very nice to highlight

is there a way to spit out a .rtf or something programmatically that's not as awful as dealing with console color codes?

Have you heard of this new technology that is gaining popularity. They call it a markup language but I think you should really see if html can do this

gonadic io
Feb 16, 2011

>>=

VikingofRock posted:

Repeat after me: We don't provide healthcare, we just match patients with [unlicensed] doctors!

gonadic io
Feb 16, 2011

>>=
`sudo ls`
`sudo cp "$(pwd)/Manual.pdf" ~/docs/`
now i can sftp it out

and repeat for 10 files, because stat is blocked so can't use *

kill me now please

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

JawnV6 posted:

hi, im putting things in a text file for humans to read

it sure would be nice if i could color the text, there's some common strings that would be very nice to highlight

is there a way to spit out a .rtf or something programmatically that's not as awful as dealing with console color codes?

i guarnatee you interacting with rtf programmaticaly is 100x worse than any otehr soution you can think of

Sweevo
Nov 8, 2007

i sometimes throw cables away

i mean straight into the bin without spending 10+ years in the box of might-come-in-handy-someday first

im a fucking monster

Luigi Thirty posted:

It turns out drawing a horizontal line of pixels in a 1bpp graphics mode is faster if you do it in groups of 1 byte and then figure out how many are left over at the end instead of doing it one pixel at a time :doh:

do you have to break it down to bytes? couldn't you write 32 bits in one operation and then do any cleanup at the end if the start/end points aren't on 4-byte boundaries?

Bloody
Mar 3, 2013

JawnV6 posted:

hi, im putting things in a text file for humans to read

it sure would be nice if i could color the text, there's some common strings that would be very nice to highlight

is there a way to spit out a .rtf or something programmatically that's not as awful as dealing with console color codes?

html

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

comedy answer: xml + xslt

Luigi Thirty
Apr 30, 2006

Emergency confection port.

Sweevo posted:

do you have to break it down to bytes? couldn't you write 32 bits in one operation and then do any cleanup at the end if the start/end points aren't on 4-byte boundaries?

that's Phase II

LordSaturn
Aug 12, 2007

sadly unfunny

JawnV6 posted:

hi, im putting things in a text file for humans to read

it sure would be nice if i could color the text, there's some common strings that would be very nice to highlight

is there a way to spit out a .rtf or something programmatically that's not as awful as dealing with console color codes?

IIRC MS Word has an XML format you can write. I have done this for Excel, it's idiosyncratic but not the worst

jesus WEP
Oct 17, 2004


LordSaturn posted:

IIRC MS Word has an XML format you can write. I have done this for Excel, it's idiosyncratic but not the worst

excel's schema is way more sane than word's

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

St Evan Echoes posted:

excel's schema is way more sane than word's

yeah. i had to try to come up with a template system to dump our bespoke internal document structure to word xml and it is not fun. especially if you need to do anything with comments or track changes. all of msdn's examples are broken out of the box.

jesus WEP
Oct 17, 2004


also there are like 100 libraries out there created to provide a sane interface to word's openxml, and they all implemented like 3 features and then gave up

LordSaturn
Aug 12, 2007

sadly unfunny

made a word doc with three words, one of them green, saved it. you're right, this is trash, use HTML

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

St Evan Echoes posted:

also there are like 100 libraries out there created to provide a sane interface to word's openxml, and they all implemented like 3 features and then gave up

my favorite is the one to just remove tracked changes from a document:
https://blogs.msdn.microsoft.com/er...ssing-document/

im just gonna post the whole source code. why is this not just a builtin function in the office sdk? gently caress you thats why:

C# code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Linq;
using DocumentFormat.OpenXml.Packaging;

namespace AcceptRevisions
{
    public static class LocalExtensions
    {
        public static XDocument GetXDocument(this OpenXmlPart part)
        {
            XDocument xdoc = part.Annotation<XDocument>();
            if (xdoc != null)
                return xdoc;
            using (StreamReader sr = new StreamReader(part.GetStream()))
                using (XmlReader xr = XmlReader.Create(sr))
                    xdoc = XDocument.Load(xr);
            part.AddAnnotation(xdoc);
            return xdoc;
        }
    }

    class Program
    {
        /// <summary>
        /// Accepts all text change revisions for one part
        /// </summary>
        private static void AcceptRevisionsForPart(OpenXmlPart part)
        {
            XNamespace w = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
            XNamespace m = "http://schemas.openxmlformats.org/officeDocument/2006/math";

            XDocument xDoc = part.GetXDocument();

            // Accept inserted text, run properties for paragraph marks, etc.
            // =============================================================================

            // Find all w:ins elements, remove the w:ins element and move its children nodes
            // up one level.
            //
            // Before:
            //
            //<w:p w:rsidR="005C743F"
            //     w:rsidRDefault="005C743F">
            //    <w:ins w:id="1"
            //           w:author="Eric White"
            //           w:date="2008-04-27T08:33:00Z">
            //        <w:r>
            //            <w:t xml:space="preserve">Text </w:t>
            //        </w:r>
            //    </w:ins>
            //    <w:r>
            //        <w:t>inserted at the beginning of the paragraph.</w:t>
            //    </w:r>
            //</w:p>
            //
            // After:
            //
            //<w:p w:rsidR="005C743F"
            //     w:rsidRDefault="005C743F">
            //    <w:r>
            //        <w:t xml:space="preserve">Text </w:t>
            //    </w:r>
            //    <w:r>
            //        <w:t>inserted at the beginning of the paragraph.</w:t>
            //    </w:r>
            //</w:p>
            //
            // Some of the w:ins elements have no children, for instance a run property that
            // indicates that a paragraph has been inserted looks like this:
            //
            //<w:p w:rsidR="005C743F"
            //     w:rsidRDefault="005C743F">
            //    <w:pPr>
            //        <w:rPr>
            //            <w:ins w:id="2"
            //                   w:author="Eric White"
            //                   w:date="2008-04-27T08:34:00Z"/>
            //        </w:rPr>
            //    </w:pPr>
            //    <w:r>
            //        <w:t xml:space="preserve">Text inserted at the end of the </w:t>
            //    </w:r>
            //    <w:r>
            //        <w:t>paragraph.</w:t>
            //    </w:r>
            //</w:p>
            //
            // and we want it to look like this:
            //
            //<w:p w:rsidR="005C743F"
            //     w:rsidRDefault="005C743F">
            //    <w:pPr>
            //        <w:rPr>
            //        </w:rPr>
            //    </w:pPr>
            //    <w:r>
            //        <w:t xml:space="preserve">Text inserted at the end of the </w:t>
            //    </w:r>
            //    <w:r>
            //        <w:t>paragraph.</w:t>
            //    </w:r>
            //</w:p>
            //
            // There are no child nodes of that w:ins element, so the following code works properly
            // to accept this revision too.

            foreach (var x in xDoc.Descendants(w + "ins").ToList())
                x.ReplaceWith(x.Nodes());

            // Accept deleted paragraphs.
            // =============================================================================
            //
            // Find all w:p/w:pPr/w:rPr/w:del nodes, append all child nodes of the following paragraph
            // to the paragraph containing the w:p/w:pPr/w:rPr/w:del node, delete the following paragraph,
            // and delete the w:p/w:pPr/w:rPr/w:del node.
            //
            // Before:
            //
            //<w:p w:rsidR="004A3F21"
            //     w:rsidDel="004A3F21"
            //     w:rsidRDefault="004A3F21"
            //     w:rsidP="008A4F80">
            //    <w:pPr>
            //        <w:rPr>
            //            <w:del w:id="17"
            //                   w:author="Eric White"
            //                   w:date="2008-04-27T13:02:00Z" />
            //        </w:rPr>
            //    </w:pPr>
            //    <w:r>
            //        <w:t xml:space="preserve">This paragraph is joined </w:t>
            //    </w:r>
            //</w:p>
            //<w:p w:rsidR="004A3F21"
            //     w:rsidRDefault="004A3F21"
            //     w:rsidP="008A4F80">
            //    <w:r>
            //        <w:t>with this paragraph.</w:t>
            //    </w:r>
            //</w:p>
            //
            // After:
            //
            //<w:p w:rsidR="004A3F21"
            //     w:rsidDel="004A3F21"
            //     w:rsidRDefault="004A3F21"
            //     w:rsidP="008A4F80">
            //    <w:pPr>
            //        <w:rPr>
            //        </w:rPr>
            //    </w:pPr>
            //    <w:r>
            //        <w:t xml:space="preserve">This paragraph is joined </w:t>
            //    </w:r>
            //    <w:r>
            //        <w:t>with this paragraph.</w:t>
            //    </w:r>
            //</w:p>

            foreach (var x in xDoc.Descendants(w + "p")
                                  .Elements(w + "pPr")
                                  .Elements(w + "rPr")
                                  .Elements(w + "del")
                                  .Reverse()
                                  .ToList())
            {
                // find the w:p element
                XElement p = x.Ancestors(w + "p").First();

                // add the elements of the paragraph following.  This code will work even if there
                // is no following paragraph.
                p.Add(p.ElementsAfterSelf(w + "p").Take(1).Elements());

                // Remove the next paragraph if there is one.
                p.ElementsAfterSelf(w + "p").Take(1).Remove();

                // remove the w:p/w:pPr/w:rPr/w:del node
                x.Remove();
            }

            // Accept changes for changes in formatting on paragraphs.
            // Accept changes for changes in formatting on runs.
            // Accept changes for applied styles to a table.
            // Accept changes for grid changes to a table.
            // Accept changes for column properties.
            // Accept changes for row properties.
            // Accept revisions for table level property exceptions.
            // Accept revisions for section properties.
            var pPrChange = w + "pPrChange";
            var rPrChange = w + "rPrChange";
            var tblPrChange = w + "tblPrChange";
            var tblGridChange = w + "tblGridChange";
            var tcPrChange = w + "tcPrChange";
            var trPrChange = w + "trPrChange";
            var tblPrExChange = w + "tblPrExChange";
            var sectPrChange = w + "sectPrChange";
            xDoc.Descendants()
                .Where(x =>
                        x.Name == pPrChange ||
                        x.Name == rPrChange ||
                        x.Name == tblPrChange ||
                        x.Name == tblGridChange ||
                        x.Name == tcPrChange ||
                        x.Name == trPrChange ||
                        x.Name == tblPrExChange ||
                        x.Name == sectPrChange)
                .Remove();

            // Accept changes for deleted rows in tables.
            // Find all w:tr/w:trPr/w:del elements, and remove the w:tr elements.
            foreach (var x in xDoc.Descendants(w + "tr")
                                  .Elements(w + "trPr")
                                  .Elements(w + "del")
                                  .ToList())
                x.Parent.Parent.Remove();

            // Accept deleted text in paragraphs.
            // =============================================================================
            //
            // Remove all w:p/w:del nodes.
            //
            // Before:
            //
            //<w:p w:rsidR="005C743F"
            //     w:rsidRDefault="005C743F"
            //     w:rsidP="005C743F">
            //    <w:r>
            //        <w:t xml:space="preserve">This line contains </w:t>
            //    </w:r>
            //    <w:del w:id="8"
            //           w:author="Eric White"
            //           w:date="2008-04-27T08:37:00Z">
            //        <w:r w:rsidDel="005C743F">
            //            <w:delText xml:space="preserve">deleted </w:delText>
            //        </w:r>
            //    </w:del>
            //    <w:r>
            //        <w:t>text.</w:t>
            //    </w:r>
            //</w:p>
            //
            // After:
            //
            //<w:p w:rsidR="005C743F"
            //     w:rsidRDefault="005C743F"
            //     w:rsidP="005C743F">
            //    <w:r>
            //        <w:t xml:space="preserve">This line contains </w:t>
            //    </w:r>
            //    <w:r>
            //        <w:t>text.</w:t>
            //    </w:r>
            //</w:p>

            // The Remove extension method uses snapshot semantics.
            //xDoc.Descendants(w + "p")
            //    .Elements(w + "del")
            //    .Remove();
            xDoc.Descendants(w + "del")
                .Remove();

            // Currently this code doesn't handle:
            // w:tblStylePr/w:trPr/w:del
            // w:style/w:trPr/w:del
            // MathML
            // Smart tags
            // Custom XML

            // I don't believe that the following is strictly necessary, but not sure.  I notice that if
            // you remove all rows from a table, and open and save using Word 2007, tables with no rows are deleted.
            // In any case, remove the tables that no longer have rows.
            xDoc.Descendants(w + "tbl")
                .Where(x => !x.Elements(w + "tr").Any())
                .Remove();

            // Accept moved paragraphs.
            // Find all w:p/w:moveFrom elements, and remove the w:p element.
            // Remove all w:moveFromRangeEnd elements
            // Find all w:p/w:moveTo elements, remove the w:moveTo elements, and promote their children to
            // be children of the w:p element
            // Remove all w:moveToRangeStart and w:moveToRangeEnd elements
            foreach (var x in xDoc.Descendants(w + "p").Elements(w + "moveFrom").ToList())
            {
                var p = x.Ancestors(w + "p").First();
                p.Remove();
            }
            xDoc.Descendants(w + "moveFromRangeEnd").Remove();
            foreach (var x in xDoc.Descendants(w + "p")
                                  .Elements(w + "moveTo")
                                  .ToList())
                x.ReplaceWith(x.Nodes());
            xDoc.Descendants(w + "moveToRangeStart").Remove();
            xDoc.Descendants(w + "moveToRangeEnd").Remove();

            using (XmlWriter xw = XmlWriter.Create(part.GetStream(FileMode.Create, FileAccess.Write)))
                xDoc.Save(xw);
        }

        /// <summary>
        /// Accepts all text change revisions in the document
        /// </summary>
        public static void AcceptAll(WordprocessingDocument document)
        {
            MainDocumentPart mainPart = document.MainDocumentPart;
            AcceptRevisionsForPart(mainPart);
            foreach (var p in mainPart.HeaderParts)
                AcceptRevisionsForPart(p);
            foreach (var p in mainPart.FooterParts)
                AcceptRevisionsForPart(p);
        }

        static void Main(string[] args)
        {
            using (WordprocessingDocument doc = WordprocessingDocument.Open("Test.docx", true))
            {
                AcceptAll(doc);
            }
        }
    }
}

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.
Well, there's always the Microsoft.Office.Interop libraries. It's been like 10 years since I had to use those, but I remember them being fairly usable. No idea what state they are in now.

JawnV6
Jul 4, 2004

So hot ...

LeftistMuslimObama posted:

i guarnatee you interacting with rtf programmaticaly is 100x worse than any otehr soution you can think of
it's actually worse than console color codes? impressive

should've mentioned that the human is probably going to edit it, static html in a browser doesn't work

Flat Daddy
Dec 3, 2014

by Nyc_Tattoo
make your program write some easy format like html and then convert with pandoc from html to rtf

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
i want to make my own bespoke data interchange format that uses ascii control codes 28-31: file separator, group separator, record separator and unit separator. if the data contains any of those codes, they will be escaped with 27, escape.

VikingofRock
Aug 24, 2008




Wheany posted:

i want to make my own bespoke data interchange format that uses ascii control codes 28-31: file separator, group separator, record separator and unit separator. if the data contains any of those codes, they will be escaped with 27, escape.

I like it.

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.

Wheany posted:

i want to make my own bespoke data interchange format that uses ascii control codes 28-31: file separator, group separator, record separator and unit separator. if the data contains any of those codes, they will be escaped with 27, escape.

I'd be tempted to use this on my production code.

distortion park
Apr 25, 2011


Finster Dexter posted:

Well, there's always the Microsoft.Office.Interop libraries. It's been like 10 years since I had to use those, but I remember them being fairly usable. No idea what state they are in now.

Then you've got to run a word instance though which is even worse than dealing with a massive xml spec













jks you're going to be doing it anyway once your boss gets his hands on your generated word reports

distortion park
Apr 25, 2011


qntm posted:

I use SO as a passive-aggressive outlet for my hatred of most programming things

"why does X behave in this confusing, dumb way? oh, because it's stupid and bad, okay"

loads of the r posters are really defensive about the language and tell newbies they are just doing stuff in the wrong way. I often want to comfort people that it's not them being stupid it's r.

GameCube
Nov 21, 2006

quiggy posted:

ive hosed about with this in both visual studio and eclipse and couldn't get either to work

admittedly this was some time ago so maybe they have improved

viemu is the only one worth poo poo, though ideavim is half-decent in pycharm. i have not only paid for viemu, i have renewed my license

Deep Dish Fuckfest
Sep 6, 2006

Advanced
Computer Touching


Toilet Rascal

Wheany posted:

i want to make my own bespoke data interchange format that uses ascii control codes 28-31: file separator, group separator, record separator and unit separator. if the data contains any of those codes, they will be escaped with 27, escape.

please also provide an official spec for converting to/from ebcdic machines ty

jesus WEP
Oct 17, 2004


pointsofdata posted:

loads of the r posters are really defensive about the language and tell newbies they are just doing stuff in the wrong way. I often want to comfort people that it's not them being stupid it's r.
go find a question about why css doesn't have inline quotes if you want to lol @ defensive babbies

Sapozhnik
Jan 2, 2005

Nap Ghost
i'm happy to see python ascendant as the new language of numerical computing, even if it is probably going to be python 2 for ever and loving ever

it's still a poo poo of a lot better than r and perl

you can gently caress up python programming, sure, it's just that you have to put your mind to it slightly more than you would with other langs.

Bloody
Mar 3, 2013

python sucks

Soricidus
Oct 21, 2010
freedom-hating statist shill

Bloody posted:

python sucks

python sucks less than most of the things it's displaced

Bloody
Mar 3, 2013

yes, but that does not mean it does not suck

Flat Daddy
Dec 3, 2014

by Nyc_Tattoo
I've been writing python for the past few days and it's really annoying even compared to javascript IMO

Flat Daddy
Dec 3, 2014

by Nyc_Tattoo
at least there's PEP-484. I'm going back and adding types because i don't understand my own code anymore

Shaggar
Apr 26, 2006

JawnV6 posted:

hi, im putting things in a text file for humans to read

it sure would be nice if i could color the text, there's some common strings that would be very nice to highlight

is there a way to spit out a .rtf or something programmatically that's not as awful as dealing with console color codes?

use the openxml sdk to create word docs.

Adbot
ADBOT LOVES YOU

Shaggar
Apr 26, 2006

St Evan Echoes posted:

also there are like 100 libraries out there created to provide a sane interface to word's openxml, and they all implemented like 3 features and then gave up

the official Microsoft one works fine

  • Locked thread