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.
 
  • Post
  • Reply
Che Delilas
Nov 23, 2009
FREE TIBET WEED

Inverness posted:

"Xbox, show me something awful."

I don't understand, why does it just keep showing me the Xbone home screen?

Adbot
ADBOT LOVES YOU

roadhead
Dec 25, 2001

X-Posted because I found the general programming thread first...

Windows 7, C# control. When my Form is "full screen" all widths that I can read seem to be 16 pixels bigger than they should be? Ie instead of 1920 its 1936 - what the gently caress did I do?

This is really loving me up when I paste a full copy of my form to the clipboard as I end up with those 16 pixels on the far right side having nothing drawn there.


There is no WAY its exactly 16 pixels of "gutter" at every resolution right?

roadhead fucked around with this message at 21:59 on Mar 4, 2015

GI_Clutch
Aug 22, 2000

by Fluffdaddy
Dinosaur Gum

roadhead posted:

X-Posted because I found the general programming thread first...

Windows 7, C# control. When my Form is "full screen" all widths that I can read seem to be 16 pixels bigger than they should be? Ie instead of 1920 its 1936 - what the gently caress did I do?

This is really loving me up when I paste a full copy of my form to the clipboard as I end up with those 16 pixels on the far right side having nothing drawn there.


There is no WAY its exactly 16 pixels of "gutter" at every resolution right?

Try using the form's ClientSize.Height and ClientSize.Width properties. These ignore any sort of window border. My monitor is also 1920, but it returns 1936 if it is maximized and I call the form's Width property, whereas ClientSize will return the size of the actual usable area (1920).

roadhead
Dec 25, 2001

GI_Clutch posted:

Try using the form's ClientSize.Height and ClientSize.Width properties. These ignore any sort of window border. My monitor is also 1920, but it returns 1936 if it is maximized and I call the form's Width property, whereas ClientSize will return the size of the actual usable area (1920).

Not true in my case for some reason, however http://blogs.msdn.com/b/oldnewthing/archive/2015/03/04/10597470.aspx was posted in the other thread and I just check the WindowState now to decide if I should subtract those 16 pixels or not.

Dirty hack that it is :(

UberJumper
May 20, 2007
woop
Why is DateTime considering invalid ISO8601 datetime strings as valid?

For example "2015-02-18T15:46:23-28:30" has a -28 hour timezone offset, which seems to simply just shift the date by -28 hours.

e.g.

code:
            DateTime dt;
            var isGood = DateTime.TryParse("2015-02-18T15:46:23-28:30", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out dt);
TryExactParse seems to prevent this case, but it causes other Valid 8601 datetime strings to be considered invalid.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Built in support for outer space time.

gariig
Dec 31, 2004
Beaten into submission by my fiance
Pillbug
I'd probably post it to StackOverflow and hope Jon Skeet answers it. You can also check out Nodatime (from Jon Skeet)

UberJumper
May 20, 2007
woop
The solution is apparently to use the DateTimeOffset, which seems to be nearly identical to DateTime, it just has better support for some things.

https://msdn.microsoft.com/en-us/library/system.datetimeoffset(v=vs.100).aspx

:psyduck:

raminasi
Jan 25, 2005

a last drink with no ice

UberJumper posted:

The solution is apparently to use the DateTimeOffset, which seems to be nearly identical to DateTime, it just has better support for some things.

https://msdn.microsoft.com/en-us/library/system.datetimeoffset(v=vs.100).aspx

:psyduck:

Sometimes exploring the .NET framework library feels like going on an archaeological dig.

Destroyenator
Dec 27, 2004

Don't ask me lady, I live in beer
Yep.

https://github.com/dotnet/coreclr/blob/02084af832c2900cf6eac2a168c41f261409be97/src/mscorlib/src/System/Globalization/DateTimeParse.cs#L2484 posted:

code:
#if FEATURE_CORECLR // on CoreCLR DateTime is also restricted to +- 14:00, just like DateTimeOffset

invision
Mar 2, 2009

I DIDN'T GET ENOUGH RAPE LAST TIME, MAY I HAVE SOME MORE?
Noob idiot question:

At work, we do a LOT of remote admin stuff for ridiculous industry-specific hardware via SSH that eventually drops us into weird industry-specific CLI's. We've been using SecureCRT, and me and another guy have written a good 10k+ lines of code of VBS to try to automate most of it. The problem besides it being the most spaghetti of code is that there are a TON of different scripts, and inside of those are menus on menus on menus that have to be navigated through. There's also no source or build or distribution control or anything, so on a team of 20 people, we all have slightly different versions of the scripts, and then there's complaining when someone runs into an outdated script, or has a problem with whatever code they mangled together through google. There's also some functionality that I'd like to add (monitoring certain things over a period of time, etc) that can totally be done in VBS, but the combination of SecureCRT + VBS, and the way it's all handled completely kills the workflow for doing certain tasks, and quickly turns into a gigantic mess if you're trying to play with multiple pieces of hardware at once.

What I'd like to do is to create a GUI that wraps the CLI from the SSH session, while getting rid of SecureCRT and PuTTY. My coding skills outside of VBS and some very very minor arduino programming, wordpress-based PHP and CSS, and codecademy Python is basically non-existent. I played with VB6 a long time ago when it was still a semi-relevant thing, so I'm thinking of going with VB.NET since GUI creation was absolutely painless in VB6, but I'm totally open to C# (and I think that would be better for me skills-wise.)

Should I go with VB.NET or C#?

Is trying to roll-my-own SSH client going to be stupidly impossible, or is it doable?

We're constantly adding new hardware to the network, and that means new IP's that need to be added in. I'd like to have some sort of local database that will download new IP's from a server somewhere, instead of having 1k+ ip's sitting in the middle of the code.

I definitely don't mind spending a lot of time working on this, but is this possible for someone that's not-very-good at programming?

invision fucked around with this message at 02:23 on Mar 5, 2015

RICHUNCLEPENNYBAGS
Dec 21, 2010

invision posted:

Noob idiot question:

At work, we do a LOT of remote admin stuff for ridiculous industry-specific hardware via SSH that eventually drops us into weird industry-specific CLI's. We've been using SecureCRT, and me and another guy have written a good 10k+ lines of code of VBS to try to automate most of it. The problem besides it being the most spaghetti of code is that there are a TON of different scripts, and inside of those are menus on menus on menus that have to be navigated through. There's also no source or build or distribution control or anything, so on a team of 20 people, we all have slightly different versions of the scripts, and then there's complaining when someone runs into an outdated script, or has a problem with whatever code they mangled together through google. There's also some functionality that I'd like to add (monitoring certain things over a period of time, etc) that can totally be done in VBS, but the combination of SecureCRT + VBS, and the way it's all handled completely kills the workflow for doing certain tasks, and quickly turns into a gigantic mess if you're trying to play with multiple pieces of hardware at once.

What I'd like to do is to create a GUI that wraps the CLI from the SSH session, while getting rid of SecureCRT and PuTTY. My coding skills outside of VBS and some very very minor arduino programming, wordpress-based PHP and CSS, and codecademy Python is basically non-existent. I played with VB6 a long time ago when it was still a semi-relevant thing, so I'm thinking of going with VB.NET since GUI creation was absolutely painless in VB6, but I'm totally open to C# (and I think that would be better for me skills-wise.)

Should I go with VB.NET or C#?

Is trying to roll-my-own SSH client going to be stupidly impossible, or is it doable?

We're constantly adding new hardware to the network, and that means new IP's that need to be added in. I'd like to have some sort of local database that will download new IP's from a server somewhere, instead of having 1k+ ip's sitting in the middle of the code.

I definitely don't mind spending a lot of time working on this, but is this possible for someone that's not-very-good at programming?
OK, here's me answering the questions you asked:

C# and VB.NET have almost the exact same features, but C# is way more widely used and also jobs in it tend to pay better. I'd use C# if I were you.

Also, why get rid of existing SSH clients? I would write a program that wrapped them, probably. It would take a really long time to actually replicate their functionality and you're likely to mess it up.

However, perhaps that's the wrong question... it sounds like if you cleaned up the scripts you had and created a Git repository it might be a good starting point. Actually I'd start with the source control. If you still need to clean up or even just rewrite your progrma in C# afterward, sure, go ahead. But a lot of the problems you're talking about will not go away without it, whether you rewrite or not.

e: Oh, for the IPs, you can definitely use a database, but a configuration file in JSON or XML or something might be fine. Or even delimiter-separated text if it's nothing more than a list of IPs.

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION
I'm using Visual Studio 2013 and I like the Task List and the way it can pick up the "TODO" comments you've left in your code. I'm wondering if there's a way to filter this list by project - I'm working collaboratively on a particular solution and we rarely touch each other's projects so I'd like to just see TODOs for my own project if possible?

crashdome
Jun 28, 2011
:science: Custom Tokens are cool!

raminasi
Jan 25, 2005

a last drink with no ice
Does anybody know why an application built against log4net 1.2.13 would think it needs log4net 1.2.11 as well and fail to run? It happens on some computers but not others.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



GrumpyDoctor posted:

Does anybody know why an application built against log4net 1.2.13 would think it needs log4net 1.2.11 as well and fail to run? It happens on some computers but not others.

An old version of one of your assemblies might get loaded from the GAC and expect the old version but a newer assembly might be asking for the newer version? Then I suppose that begs the question of how that old assembly of yours is still GACed but not the old library assembly, so maybe I'm talking out of my rear end.

raminasi
Jan 25, 2005

a last drink with no ice

Munkeymon posted:

An old version of one of your assemblies might get loaded from the GAC and expect the old version but a newer assembly might be asking for the newer version? Then I suppose that begs the question of how that old assembly of yours is still GACed but not the old library assembly, so maybe I'm talking out of my rear end.

If I'm understanding your hypothesis right, that can't be it, because this happens with fresh installs, and we've never used the older version.

Eggnogium
Jun 1, 2010

Never give an inch! Hnnnghhhhhh!
I am calling a library method that takes a Func<Task<long>> as a parameter so it can await it in case the method is async. However, in my case I just want to return a List<T> object's count. Is the right way to do this just to pass in this:

code:
() => new Task<long>( () => myList.Count)
Seems oddly verbose.

Sedro
Dec 31, 2008
You should use FromResult if you already know the result
C# code:
() => Task.FromResult(myList.Count)

Eggnogium
Jun 1, 2010

Never give an inch! Hnnnghhhhhh!

Sedro posted:

You should use FromResult if you already know the result
C# code:
() => Task.FromResult(myList.Count)

Perfect, thank you!

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



GrumpyDoctor posted:

If I'm understanding your hypothesis right, that can't be it, because this happens with fresh installs, and we've never used the older version.

Correct - I was assuming an in-place upgrade without a restart.

Quebec Bagnet
Apr 28, 2009

mess with the honk
you get the bonk
Lipstick Apathy

GrumpyDoctor posted:

Does anybody know why an application built against log4net 1.2.13 would think it needs log4net 1.2.11 as well and fail to run? It happens on some computers but not others.

Is one of its dependencies referencing 1.2.11? IIRC that was the version that log4net switched to a new code signing key, which broke usage when some assemblies in an AppDomain referenced an assembly with the old key and some referenced one with the new. As for happening on some computers and not others, it could be that the old version is being picked up from the GAC for some.

e: I realize Munkeymon already asked it but be sure to check third-party assemblies too.

raminasi
Jan 25, 2005

a last drink with no ice

chmods please posted:

Is one of its dependencies referencing 1.2.11? IIRC that was the version that log4net switched to a new code signing key, which broke usage when some assemblies in an AppDomain referenced an assembly with the old key and some referenced one with the new. As for happening on some computers and not others, it could be that the old version is being picked up from the GAC for some.

e: I realize Munkeymon already asked it but be sure to check third-party assemblies too.

My dependency tree is very small, and I can only find a reference to 1.2.13. I used Process Monitor and some step-through debugging, and I'm pretty sure that this dependency is actually trying to load both 1.2.11 and 1.2.13 (I can tell by the paths in the GAC it checks.) According to Process Monitor, the version that NuGet installed (1.2.13) satisfies it in its quest for 1.2.11, but I guess not on all computers.

The worst part of all this is that I don't even use the stupid logging functionality.

Hughmoris
Apr 21, 2007
Let's go to the abyss!
Is there a simple way to iterate through regex matches in C#?

For instance, if I have a string: "Test string 123 and another 456 and a third 789"
And I want to capture any three digits that are together, I think my regex pattern would be "(\\d\\d\\d)"

I'd like to regex the test string and have an output of:

123
456
789

The little snippets I can find online seem overly complicated for iterating through matches.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

I don't have an IDE in front of me, but isn't matches just a collection? So something like
code:
Dim strFind As String = "[0-9][0-9][0-9]"
Dim strSearch As String = "Test string 123 and another 456 and a third 789"
Dim strResults as New List(Of String)
Dim regLook As New Regex(strFind, RegexOptions.IgnoreCase)
Dim m As Match = regLook.Match(strSearch)
For Each mm As Match In m.Groups
 strResults.Add(mm.Value)
Next
or am I smoking crack?

Hughmoris
Apr 21, 2007
Let's go to the abyss!

Scaramouche posted:

I don't have an IDE in front of me, but isn't matches just a collection? So something like
code:
Dim strFind As String = "[0-9][0-9][0-9]"
Dim strSearch As String = "Test string 123 and another 456 and a third 789"
Dim strResults as New List(Of String)
Dim regLook As New Regex(strFind, RegexOptions.IgnoreCase)
Dim m As Match = regLook.Match(strSearch)
For Each mm As Match In m.Groups
 strResults.Add(mm.Value)
Next
or am I smoking crack?

Well, that looks about what I've been seeing. I think I'm just a little daunted by the wordiness of it, coming from Python. Ok, I'll sit down and try to work my way through that.

raminasi
Jan 25, 2005

a last drink with no ice
I believe that the example you posted will actually yield a collection in Groups[0].Captures, but I'm not entirely sure without playing around with it myself.

Hughmoris
Apr 21, 2007
Let's go to the abyss!
I found a solution that I think is easy enough for me to remember.

code:

        static void Main(string[] args)
        {
            string sPattern = ("\\d\\d\\d");
            string testString = "james is 123 and 456 and 83823 jas 432";

            Match foundMatches = Regex.Match(testString, sPattern);

            while(foundMatches.Success)
            {
                Console.WriteLine("I found {0}", foundMatches.Value);
                foundMatches = foundMatches.NextMatch();
            }


        }

RICHUNCLEPENNYBAGS
Dec 21, 2010
Yeah, frankly, the regex matching stuff is kinda lame.

Gul Banana
Nov 28, 2003

just use Regex.Matches, which returns a collection straight up

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

GrumpyDoctor posted:

I believe that the example you posted will actually yield a collection in Groups[0].Captures, but I'm not entirely sure without playing around with it myself.

That could well be, I'm helpless like a baby without Intellisense/Autocomplete.

chippy
Aug 16, 2006

OK I DON'T GET IT

Hughmoris posted:

Is there a simple way to iterate through regex matches in C#?

For instance, if I have a string: "Test string 123 and another 456 and a third 789"
And I want to capture any three digits that are together, I think my regex pattern would be "(\\d\\d\\d)"

I'd like to regex the test string and have an output of:

123
456
789

The little snippets I can find online seem overly complicated for iterating through matches.


code:
string testString = "Test string 123 and another 456 and a third 789";
Regex testRegex = new Regex(@"\d\d\d", RegexOptions.Compiled);
foreach (Match testMatch in testRegex.Matches(testString))
{
	Console.WriteLine(testMatch.Value);
}
Match has other properties you can access too if you need more than just the matched string. Using @ before the string means you don't have to escape your escape characters.

Mr Shiny Pants
Nov 12, 2012
God F# is a nice language. Especially with type providers.

What ORM?

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Hughmoris posted:

I found a solution that I think is easy enough for me to remember.

LINQPad might be a big help when you're trying to visualize object structure:

Blasphemeral
Jul 26, 2012

Three mongrel men in exchange for a party member? I found that one in the Faustian Bargain Bin.
Over the last year, I've taught myself WPF/XAML through excessive and varied online sources, and have developed a professional project using it paired with MVVM principles. I am sure, however, that there are a number of subtleties, tips and tricks that I have missed, and am curious if you brilliant folks could give me a recommendation:

What is the best expert-level book I could acquire on WPF with the goal of fine-tuning my skills? Or, if there isn't a great book suggestion, is there a good website?


-----

Munkeymon posted:

LINQPad might be a big help when you're trying to visualize object structure:


Wow! I had no idea there was something that could display that so nicely. I'll stow this tidbit away for later.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

EDIT - I got it working, leaving first part of the question in for historical reasons. However, I still want to limit access to this, so read on below the code to see the updated question!
Have you guys ever programmatically accessed an FTP server that requires >active< connection from .NET? I adapted my passive code to do so:
code:
        Dim request As FtpWebRequest = DirectCast(WebRequest.Create("ftp://placetoftpto/" & strFileName), FtpWebRequest)
        request.Method = WebRequestMethods.Ftp.UploadFile
        request.UseBinary = False
        request.UsePassive = False 'added this

        request.Credentials = New NetworkCredential("name", "pass")

        Dim sourceStream As New StreamReader(strFilePath)
        'Dim sourceStream As New StreamReader("C:\Feeds\Orders\Outbox\" & fileName & ".txt")
        Dim fileContents As Byte() = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd())
        sourceStream.Close()
        request.ContentLength = fileContents.Length

        Dim requestStream As Stream = request.GetRequestStream() ' error occurs here
        requestStream.Write(fileContents, 0, fileContents.Length)
        requestStream.Close()
I'm getting a "(425) Can't open data connection" error. Which I think is firewall related, but thought I'd run this by you guys first to make sure there's nothing dodgy with the code.

The instructions from the person running the server are:

quote:

IMPORTANT!! Please ensure that you are in "Active" mode as "Passive" mode will not work. Active FTP requires the clients firewall to allow traffic above > 1023 from port 20 & 21. Port 20 is the data communication port that most people forget to allow. Check both hardware firewalls and software firewalls like (XP firewall).

Which I believe I've done by making a pretty blanket rule of :
-> In TCP
Remote Port: Any
Local Port: 20,21,1024-65535
and
<- Out TCP
Remote Port: Any
Local Port: 20,21,1024-65535

But it still doesn't work, even in command line FTP (which is why I think it's a firewall problem). I know firewall questions are a bit outside the scope of this thread, but couldn't really figure out a place to put the second part of this question, which is: how to configure the firewall to let active ftp through.
EDIT - This is the real question now
And the last question is, if I want to limit this access to only my web application, how would I do that? Limit it to the app pool user name in the firewall?

Scaramouche fucked around with this message at 22:36 on Mar 6, 2015

Mr Shiny Pants
Nov 12, 2012

Scaramouche posted:

EDIT - I got it working, leaving first part of the question in for historical reasons. However, I still want to limit access to this, so read on below the code to see the updated question!
Have you guys ever programmatically accessed an FTP server that requires >active< connection from .NET? I adapted my passive code to do so:
code:
        Dim request As FtpWebRequest = DirectCast(WebRequest.Create("ftp://placetoftpto/" & strFileName), FtpWebRequest)
        request.Method = WebRequestMethods.Ftp.UploadFile
        request.UseBinary = False
        request.UsePassive = False 'added this

        request.Credentials = New NetworkCredential("name", "pass")

        Dim sourceStream As New StreamReader(strFilePath)
        'Dim sourceStream As New StreamReader("C:\Feeds\Orders\Outbox\" & fileName & ".txt")
        Dim fileContents As Byte() = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd())
        sourceStream.Close()
        request.ContentLength = fileContents.Length

        Dim requestStream As Stream = request.GetRequestStream() ' error occurs here
        requestStream.Write(fileContents, 0, fileContents.Length)
        requestStream.Close()
I'm getting a "(425) Can't open data connection" error. Which I think is firewall related, but thought I'd run this by you guys first to make sure there's nothing dodgy with the code.

The instructions from the person running the server are:


Which I believe I've done by making a pretty blanket rule of :
-> In TCP
Remote Port: Any
Local Port: 20,21,1024-65535
and
<- Out TCP
Remote Port: Any
Local Port: 20,21,1024-65535

But it still doesn't work, even in command line FTP (which is why I think it's a firewall problem). I know firewall questions are a bit outside the scope of this thread, but couldn't really figure out a place to put the second part of this question, which is: how to configure the firewall to let active ftp through.
EDIT - This is the real question now
And the last question is, if I want to limit this access to only my web application, how would I do that? Limit it to the app pool user name in the firewall?

In the windows firewall you could configure a rule that allows incoming ports from his IP Address. 1023 and up. As for your application just add the executable to "Let an application through windows firewall" configuration. Or the W3wp process.

Hughmoris
Apr 21, 2007
Let's go to the abyss!

Munkeymon posted:

LINQPad might be a big help when you're trying to visualize object structure:


This is pretty cool, I'll have to check it out. I've seen the LINQ term being tossed about but I haven't really looked at it or know what it is.

I'm running into a new issue with my regex function. I'm capturing more characters than I want. An example test string would be:
code:
something something| ACCESS_ID:8812 something || jsme CUST_ID:998192 blah blah blah
My regex expression of "ACCESS_ID:(\d\d\d\d)" is capturing and printing out that entire block ACCESS_ID:8812 instead of just the number 8812. Any ideas on how I should adjust that?

*The ACCESS_ID: value can vary in length, won't always be 4 digits.

UberJumper
May 20, 2007
woop
So apparently after writing C# unit tests for half a week. I have apparently just inherited all responsibilities as lead test developer. The company is small (~20 people), and honestly even after saying "This is a bad idea" and i don't know anything about being lead test developer, they still put me in this position.

The old lead left on apparently bad terms, and there is absolutely no documentation. There is apparently a Jenkins server, that seems to be pulling from a SVN (we swapped to git a year ago). Apparently they just want to start from scratch when it comes to testing, and i am at a complete and utter loss. Does anyone have any tips for doing this kind of degree of testing for C#.

Adbot
ADBOT LOVES YOU

brap
Aug 23, 2004

Grimey Drawer
Get just the capture group. Groups have automatic number identifiers or can be named. Google knows. Also, write \d{4} not \d\d\d\d.

UberJumper posted:

So apparently after writing C# unit tests for half a week. I have apparently just inherited all responsibilities as lead test developer. The company is small (~20 people), and honestly even after saying "This is a bad idea" and i don't know anything about being lead test developer, they still put me in this position.

The old lead left on apparently bad terms, and there is absolutely no documentation. There is apparently a Jenkins server, that seems to be pulling from a SVN (we swapped to git a year ago). Apparently they just want to start from scratch when it comes to testing, and i am at a complete and utter loss. Does anyone have any tips for doing this kind of degree of testing for C#.

Make sure to check in with the coding horrors thread.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply