As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/
Options

[Programming] Kafkaesque rabbits in the queue at the pub

16263656768100

Posts

  • Options
    EchoEcho ski-bap ba-dapModerator mod
    Hey, check my amazingly shitty IRC client! It only took me way to long to actually send data to the server because as usual I forgot AutoFlush = true on the StreamWriter.

    Now to actually implement the protocol.

    ler79hhh93az.png

  • Options
    SeolSeol Registered User regular
    Echo wrote: »
    An infinite number of mathematicians walk into a bar. The first one orders half a beer. The second orders a quarter beer. The third orders one eighth of a beer.

    The bartender goes "I hate you" and gives them two beers.
    Bartender should say "you should really know your limits" there...

  • Options
    bowenbowen How you doin'? Registered User regular
    @echo you should toss that shit on github

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    EchoEcho ski-bap ba-dapModerator mod
    I think I might when I've cleaned it up a bit, right now I make things up as I go and it shows.

  • Options
    EchoEcho ski-bap ba-dapModerator mod
    edited March 2017
    I may have taken too much of a liking to IndexOf() to do (basic) string checks.
    public static bool IsChannel(this string value)
    {
        bool hasHash = value.IndexOf('#') == 0;
        bool noSpaces = value.IndexOf(' ') == -1;
    
        return hasHash && noSpaces;
    }
    

    Echo on
  • Options
    djmitchelladjmitchella Registered User regular
    Does anyone have a recommendation for a site with a decent quick starter intro to SQL? Every so often there's stuff that needs changing here, and I'd like to be able to do it myself rather than always having to ask one of the folks that understands it. I sort of recognise some of the concepts by osmosis, but it feels like there's some really fundamental stuff that I don't know.

  • Options
    YoshuaYoshua Registered User regular
    edited March 2017
    Surprisingly, I found a lot of good tutorials at W3 Schools.

    I'll happily answer any questions I can as well. My experience is with Transact SQL.

    Yoshua on
  • Options
    bowenbowen How you doin'? Registered User regular
    yeah as much as people rag on w3 schools

    it's a pretty good "beginners" resource or reference sheet

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    bowenbowen How you doin'? Registered User regular
    Echo wrote: »
    I may have taken too much of a liking to IndexOf() to do (basic) string checks.
    public static bool IsChannel(this string value)
    {
        bool hasHash = value.IndexOf('#') == 0;
        bool noSpaces = value.IndexOf(' ') == -1;
    
        return hasHash && noSpaces;
    }
    

    what happens if someone drops #poopybutt without typing spaces?

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    schussschuss Registered User regular
    Does anyone have a recommendation for a site with a decent quick starter intro to SQL? Every so often there's stuff that needs changing here, and I'd like to be able to do it myself rather than always having to ask one of the folks that understands it. I sort of recognise some of the concepts by osmosis, but it feels like there's some really fundamental stuff that I don't know.

    SQLZoo is the best tutorial series I've found. Also depends on the database, as syntax can change based on whether it's MS SQL, Oracle, Teradata etc.

  • Options
    KolosusKolosus Registered User regular
  • Options
    djmitchelladjmitchella Registered User regular
    Thanks for the sql pointers -- I'll give them a look. The code is talking to MS SQL server, with bits of entity framework in some places -- there's nothing very complicated going on, I think, but I want to make sure I have the basics of what "join" (etc) means clear in my head, rather than trying to form a mental picture just by looking at existing queries and thinking about what they do.

  • Options
    EchoEcho ski-bap ba-dapModerator mod
    bowen wrote: »
    Echo wrote: »
    I may have taken too much of a liking to IndexOf() to do (basic) string checks.
    public static bool IsChannel(this string value)
    {
        bool hasHash = value.IndexOf('#') == 0;
        bool noSpaces = value.IndexOf(' ') == -1;
    
        return hasHash && noSpaces;
    }
    

    what happens if someone drops #poopybutt without typing spaces?

    It returns true? No spaces allowed.

  • Options
    JasconiusJasconius sword criminal mad onlineRegistered User regular
    edited March 2017
    ive always thought of W3schools as a completely acceptable source for basic field reference material, especially for javascript

    i was told once by a recently graduated student that professors tell their class to not use W3 in the way that teachers told me not to use Wikipedia

    to which i say "why?"

    Jasconius on
  • Options
    zeenyzeeny Registered User regular
    edited March 2017
    Echo wrote: »
    bowen wrote: »
    Echo wrote: »
    I may have taken too much of a liking to IndexOf() to do (basic) string checks.
    public static bool IsChannel(this string value)
    {
        bool hasHash = value.IndexOf('#') == 0;
        bool noSpaces = value.IndexOf(' ') == -1;
    
        return hasHash && noSpaces;
    }
    

    what happens if someone drops #poopybutt without typing spaces?

    It returns true? No spaces allowed.

    Are you actually aiming for IRC or just doing a "chat thing"? That's far from the RFC definition of a channel name.

    zeeny on
  • Options
    EchoEcho ski-bap ba-dapModerator mod
    zeeny wrote: »
    Are you actually aiming for IRC or just doing a "chat thing"? That's far from the RFC definition of a channel name.

    So far just a chat thing. Not caring much about actual specs. That's my first 15 seconds of sanity checking a channel name.

  • Options
    zeenyzeeny Registered User regular
    Echo wrote: »
    zeeny wrote: »
    Are you actually aiming for IRC or just doing a "chat thing"? That's far from the RFC definition of a channel name.

    So far just a chat thing. Not caring much about actual specs. That's my first 15 seconds of sanity checking a channel name.

    Good luck, personal projects are a fun way to learn!

  • Options
    EchoEcho ski-bap ba-dapModerator mod
    Also I felt the two RFCs I read were pretty terribly written. I have plenty of info about how the message from the client to the server is to be formed, but only a vague idea about replies from the server.

  • Options
    bowenbowen How you doin'? Registered User regular
    as far as I know with IRC, server can send literally anything (it's extensible), protocol wise, everything appears the same way

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    Echo wrote: »
    I may have taken too much of a liking to IndexOf() to do (basic) string checks.
    public static bool IsChannel(this string value)
    {
        bool hasHash = value.IndexOf('#') == 0;
        bool noSpaces = value.IndexOf(' ') == -1;
    
        return hasHash && noSpaces;
    }
    

    Eh, you're turning an O(1) check into an O(n) one there (barring absolutely fantastic optimizer work). In practical terms it's unlikely someone routinely sends kilobyte or bigger strings but... doesn't sit right with me

  • Options
    EchoEcho ski-bap ba-dapModerator mod
    bowen wrote: »
    as far as I know with IRC, server can send literally anything (it's extensible), protocol wise, everything appears the same way

    Also code above is client-side. My general approach to this is "client can send whatever, server does sanity checking".
    Phyphor wrote: »
    Eh, you're turning an O(1) check into an O(n) one there (barring absolutely fantastic optimizer work). In practical terms it's unlikely someone routinely sends kilobyte or bigger strings but... doesn't sit right with me

    I was going to say no, but... yeah. If well-formed the hash is the first character and IndexOf() stops at the first occurence.

    CPiJMG2WwAAdwAe.png

  • Options
    EchoEcho ski-bap ba-dapModerator mod
    edited March 2017
    Also JOIN takes a second space-separated argument that is the potential password to a protected channel so that code will get scrapped anyway. :rotate:

    Echo on
  • Options
    KhavallKhavall British ColumbiaRegistered User regular
    edited March 2017
    I was trying to name a variable in a way that made if fairly clear that I was dealing with the distance(adjusted for octave) between the secondary Melody line and the bass line.


    I then realized that this variable name is actually my new favourite 90s R&B a capella group.

    I dig that Mel2Bass

    Khavall on
  • Options
    EchoEcho ski-bap ba-dapModerator mod
    I suppose I could implement that idea I got for a single-pass check to find the positions of a set of arbitrary characters in a string for situations like that.
    CPiJMG2WwAAdwAe.png

  • Options
    djmitchelladjmitchella Registered User regular
    Jasconius wrote: »
    ive always thought of W3schools as a completely acceptable source for basic field reference material, especially for javascript

    i was told once by a recently graduated student that professors tell their class to not use W3 in the way that teachers told me not to use Wikipedia

    to which i say "why?"

    It used to be really crappy, I guess? http://w3fools.com/ was at one point a list of all the things wrong on w3schools, but they seem to have cleaned up since then. https://meta.stackoverflow.com/a/280484 has more.

  • Options
    EchoEcho ski-bap ba-dapModerator mod
    w3schools used to have some actively harmful "guides".

  • Options
    SmasherSmasher Starting to get dizzy Registered User regular
    Khavall wrote: »
    I was trying to name a variable in a way that made if fairly clear that I was dealing with the distance(adjusted for octave) between the secondary Melody line and the bass line.


    I then realized that this variable name is actually my new favourite 90s R&B a capella group.

    I dig that Mel2Bass
    Is there a reason you're looping like that instead of using the modulo operator?

  • Options
    KhavallKhavall British ColumbiaRegistered User regular
    Smasher wrote: »
    Khavall wrote: »
    I was trying to name a variable in a way that made if fairly clear that I was dealing with the distance(adjusted for octave) between the secondary Melody line and the bass line.


    I then realized that this variable name is actually my new favourite 90s R&B a capella group.

    I dig that Mel2Bass
    Is there a reason you're looping like that instead of using the modulo operator?

    Mostly just because I'm an idiot and hadn't thought of it that way.

    I think because I was thinking of it from musical terms where I wanted the interval, adjusted for octave, which made me go "find difference -> adjust until the right octave"

  • Options
    EchoEcho ski-bap ba-dapModerator mod
    I'm really bad at using modulo where I could get away with it.

  • Options
    hippofanthippofant ティンク Registered User regular
    edited March 2017
    Phyphor wrote: »
    Echo wrote: »
    I may have taken too much of a liking to IndexOf() to do (basic) string checks.
    public static bool IsChannel(this string value)
    {
        bool hasHash = value.IndexOf('#') == 0;
        bool noSpaces = value.IndexOf(' ') == -1;
    
        return hasHash && noSpaces;
    }
    

    Eh, you're turning an O(1) check into an O(n) one there (barring absolutely fantastic optimizer work). In practical terms it's unlikely someone routinely sends kilobyte or bigger strings but... doesn't sit right with me

    How could the no-space check occur in O(1)? Or are you just talking about the first line? Cuz we all know that O(1) + O(n) = O(n) :rotate:

    (I wonder if compiler would be clever enough to do them both in one go?)

    hippofant on
  • Options
    PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    edited March 2017
    Yeah, just the first line. It's still doubling the work needed. I would be quite impressed if any optimizers did both checks simultaneously

    Phyphor on
  • Options
    JasconiusJasconius sword criminal mad onlineRegistered User regular
    last few weeks have been a return to full time objective-c for me and I'm amused to be reminded that NSString is still the slowest form of string type in the history of all programming languages

    want to loop a string comparison? better not have more than 1000 iterations or go ahead and do your laundry

  • Options
    bowenbowen How you doin'? Registered User regular
    gotta be unique tho!

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    JasconiusJasconius sword criminal mad onlineRegistered User regular
    im trying to do unique column constraints in CoreData and it is going.... poorly

    if i do it manually, it's performance is abysmal

    if I try to get CoreData to do it natively, I get extremely cryptic exceptions and unusual debugging events that makes me question basically everything about my implementation

    and oddly this is one of the very few things that Apple hasn't documented particularly well

  • Options
    DelzhandDelzhand Hard to miss. Registered User regular
    Just got forwarded an email:

    "How did you get my email address? How awful of you to spam me!"

    Okay, first of all? Your email address is abcdtest@gmail.com. That's on you.
    Secondly, why is the external QA team using gmail addresses to test things? There are tools for that kind of thing.

  • Options
    gavindelgavindel The reason all your software is brokenRegistered User regular
    I need to update xml metadata for about 2500 files at once. Be nice to auomate that, right? Send out an email asking if resources exist, get a response:

    "Nope, but you can always use a script to manually change the xml. Just make sure not to disrupt the node ordering or you'll nuke the entire system. 8-) "

    Well, no pressure, right?

    Book - Royal road - Free! Seraphim === TTRPG - Wuxia - Free! Seln Alora
  • Options
    OghulkOghulk Tinychat Janitor TinychatRegistered User regular
    edited March 2017
    Ok, I've finally hit a wall with teaching myself how to code, specifically with one problem.

    I'm using Python to access a local MySQL server and input values, specifically using the twitter api to do so as a test run. Everything runs perfectly fine until the twitter api cuts me off because it only supports so many calls within a 15 minute time frame. When it happens it cuts off my list of followers I'm inputting, so it stops the script in its tracks. I've got a work around for this, but if I need to run the script again, which I have to since it stops it, the api gives me integrity errors when I try to input it to the server since there's already a copy of that data in the server.

    I've come up with a few different work-arounds for this, but the main thing I'm having issue with is running a search for the value that I'm trying to input, and if its there it skips that value. I can't seem to figure out a way to do this while reducing the memory workload of the script and the amount of calls I have to make to the MySQL server.

    e: as a further example, this is what it looks like
    iYAKD4D.png

    I'm using a try and except Integrity Error, and printing that error when the except is called, but it's still doing the insert and rollback in the try/except function. Que es esto?

    Oghulk on
  • Options
    LD50LD50 Registered User regular
    Oghulk wrote: »
    I'm using a try and except Integrity Error, and printing that error when the except is called, but it's still doing the insert and rollback in the try/except function. Que es esto?

    Are you asking why the insertion and rollback are still happening?

  • Options
    OghulkOghulk Tinychat Janitor TinychatRegistered User regular
    LD50 wrote: »
    Oghulk wrote: »
    I'm using a try and except Integrity Error, and printing that error when the except is called, but it's still doing the insert and rollback in the try/except function. Que es esto?

    Are you asking why the insertion and rollback are still happening?

    Yeah. I did use a new method that has so far seemed to work but I'm having a hard time testing it since the API is still curtailing my calls, but I'd like to know why it's still happening.

  • Options
    KetBraKetBra Dressed Ridiculously Registered User regular
    You're still getting the integrity error because your code in the try clause executes until it hits the exception, which is what is causing the insertion/rollback, I think

    KGMvDLc.jpg?1
This discussion has been closed.