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/
We're funding a new Acquisitions Incorporated series on Kickstarter right now! Check it out at https://www.kickstarter.com/projects/pennyarcade/acquisitions-incorporated-the-series-2

Git Merge Squashing [Programming] Thread : Filesystems logging stuff

11920222425100

Posts

  • EchoEcho ski-bap ba-dapModerator mod
    Welp. Today I wrote shit to test Twig and converted a bunch of templates from Blade to Twig and concluded that Twig sucks and deleted that branch.

    Net progress: zero

    bowen
  • bowenbowen How you doin'? Registered User regular
    You win some you lose some.

    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
    Delmain
  • EchoEcho ski-bap ba-dapModerator mod
    At least I found an asset pipeline manager that looks promising. I'll give a spin tomorrow.

  • zeenyzeeny Registered User regular
    Any particular reason you are not using mustache or a mustache based template engine? Because you probably should.

  • EchoEcho ski-bap ba-dapModerator mod
    edited October 2013
    JSON stuff aside, that looks like Blade.

    Echo on
  • EchoEcho ski-bap ba-dapModerator mod
    At a quick glance Mustasche also does like Twig and won't let me write plain code in tags.

  • EvilMonkeyEvilMonkey Registered User regular
    I used Handlebars on my last CRUD app, which is essentially Mustache with if / for blocks and other goodies. You can also create your own helper methods / blocks, which I ended up using to do stuff like converting C# DateTime values (/Date(1381332438770)/) into local DateTime strings. It seems to do the trick for relatively simple templates.

    [PSN: SciencePiggy] [Steam]
  • urahonkyurahonky Registered User regular
    Heh. You can tell when someone's been working Government contracts too long. I suggested that I update my Java program to just go through ALL of the SQL files that we have and pull out the DB names. He said that would help but it would take a few days.

    15 minutes later I had the output.

  • DelmainDelmain Registered User regular
    urahonky wrote: »
    Heh. You can tell when someone's been working Government contracts too long. I suggested that I update my Java program to just go through ALL of the SQL files that we have and pull out the DB names. He said that would help but it would take a few days.

    15 minutes later I had the output.

    He was telling you what he was going to charge the client for it.

  • urahonkyurahonky Registered User regular
    I don't think he was meaning to be overshooting it that bad. Mischarging your time to the Government is a real bad idea. :P

  • bowenbowen How you doin'? Registered User regular
    If something takes you a few minutes you charge a few days worth of time. Because you need to test, troubleshoot, revise, and release.

    When you mark something off on your worksheet about taking 15 minutes, I guarantee you they will bill that as at least 8 hours worth of work.

    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
  • bowenbowen How you doin'? Registered User regular
    Sure I can stock shelves in the supermarket in 10 minutes. Can I do it every day? Maybe. Forever? No. Is it worth my time to always do it fast? Not really.

    Another thing most people don't know: companies charge stupidity fees if you act like an ass or waste their time.

    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
    Spawnbroker
  • SpawnbrokerSpawnbroker Registered User regular
    bowen wrote: »
    Sure I can stock shelves in the supermarket in 10 minutes. Can I do it every day? Maybe. Forever? No. Is it worth my time to always do it fast? Not really.

    Another thing most people don't know: companies charge stupidity fees if you act like an ass or waste their time.

    My company is doing this. We have a client who raked us over the coals on our last project due to a combination of mismanagement and developer incompetence on our end (both people got fired, and me and my manager took over the client). They asked for all sorts of free work that cost us a lot of money.

    So now that they've signed another contract with us, we are padding all the time on our current work by a few hours per item. I don't really like it, but hey man I just do the code. As long as the client is making happy noises at my manager and leaving me the hell alone, I'm cool :P

    Steam: Spawnbroker
  • electricitylikesmeelectricitylikesme Registered User regular
    edited October 2013
    Probably not my most productive time ever, but my little IMAP listener v2 is now running. The real test is whether 8 hours later it's still ticking along, or if it's died silently.

    It's more or less pushing the limit of what I want to put in a single Python file but oh well. What kept tripping me up was the tendency of all the subthreads that I ended up needing to hit exceptions and not die gracefully. And all this is mostly in service to my strong desire to not have any 1 second delays to try and synchronize things - everything blocks or signals when it's done and reacts immediately.

    electricitylikesme on
  • bowenbowen How you doin'? Registered User regular
    bowen wrote: »
    Sure I can stock shelves in the supermarket in 10 minutes. Can I do it every day? Maybe. Forever? No. Is it worth my time to always do it fast? Not really.

    Another thing most people don't know: companies charge stupidity fees if you act like an ass or waste their time.

    My company is doing this. We have a client who raked us over the coals on our last project due to a combination of mismanagement and developer incompetence on our end (both people got fired, and me and my manager took over the client). They asked for all sorts of free work that cost us a lot of money.

    So now that they've signed another contract with us, we are padding all the time on our current work by a few hours per item. I don't really like it, but hey man I just do the code. As long as the client is making happy noises at my manager and leaving me the hell alone, I'm cool :P

    Pure business reason for it. If you bill for exactly how long it always takes, if there's ever an issue, you have no float to cover it.

    Oh a computer breaks that was our fault? We won't get paid.
    Oh a computer breaks that was their fault? We won't get paid.

    People like to not pay.

    This is why if you're a contractor you don't use your hourly wage you'd get if you were salary. Aside from HR expenses and all that, you'll want to use almost three times your wage because you need to cover lack of work, overhead for getting tools and equipment, and dealing with assholes.

    Three times your wage is going lowball in my opinion.

    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
  • EchoEcho ski-bap ba-dapModerator mod
    edited October 2013
    Basically, if a template engine won't let me do basic shit like this, it's not for me.
    {{ Former::open()->action(URL::route('contest.store')) }}
    

    Because I like having my helper classes that spit out Bootstrapified HTML for me. I don't want to have to re-implement it by wrapping every method the helper has to make the template engine happy.

    Echo on
  • SpawnbrokerSpawnbroker Registered User regular
    bowen wrote: »
    bowen wrote: »
    Sure I can stock shelves in the supermarket in 10 minutes. Can I do it every day? Maybe. Forever? No. Is it worth my time to always do it fast? Not really.

    Another thing most people don't know: companies charge stupidity fees if you act like an ass or waste their time.

    My company is doing this. We have a client who raked us over the coals on our last project due to a combination of mismanagement and developer incompetence on our end (both people got fired, and me and my manager took over the client). They asked for all sorts of free work that cost us a lot of money.

    So now that they've signed another contract with us, we are padding all the time on our current work by a few hours per item. I don't really like it, but hey man I just do the code. As long as the client is making happy noises at my manager and leaving me the hell alone, I'm cool :P

    Pure business reason for it. If you bill for exactly how long it always takes, if there's ever an issue, you have no float to cover it.

    Oh a computer breaks that was our fault? We won't get paid.
    Oh a computer breaks that was their fault? We won't get paid.

    People like to not pay.

    This is why if you're a contractor you don't use your hourly wage you'd get if you were salary. Aside from HR expenses and all that, you'll want to use almost three times your wage because you need to cover lack of work, overhead for getting tools and equipment, and dealing with assholes.

    Three times your wage is going lowball in my opinion.

    Makes sense. I'm still getting used to this business, it's my first job and I've been out of college less than a year.

    I think I got lucky with my company, it's small enough that I can make an impact and feel important, and large enough that we aren't worried about going out of business or anything. Definitely not a corporate culture, the owner used to be the lead singer of a rock band.

    Steam: Spawnbroker
  • urahonkyurahonky Registered User regular
    TIL that doing String.trim() on a string is very, very costly.

  • bowenbowen How you doin'? Registered User regular
    urahonky wrote: »
    TIL that doing String.trim() on a string is very, very costly.

    Sure. But you don't want erroneous spaces in your strings. Doing it manually isn't going to improve it, at all.

    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
    Delmain
  • urahonkyurahonky Registered User regular
    Indeed. The Java program I wrote would go through about 20 or so files in about 15 seconds. Now it does it in probably 20 minutes lol

  • bowenbowen How you doin'? Registered User regular
    What are you doing that has increased it so much? I doubt it's just string.trim() doing that.

    That sounds like the work of replace.

    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
  • EndEnd Registered User regular
    huh I wouldn't have expected a slowdown that would be anywhere that bad

    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpgsteam~tinythumb.png
    bowenDelmain
  • WeretacoWeretaco Cubicle Gangster Registered User regular
    Ugh.. spent all morning trying to figure out why this Xml refused to deserialize properly into my custom object.

    Stupid namespaces!

    Unofficial PA IRC chat: #paforums at irc.slashnet.org
  • bowenbowen How you doin'? Registered User regular
    End wrote: »
    huh I wouldn't have expected a slowdown that would be anywhere that bad

    Yeah you'd see that kind of slowdown with a lot of regex. Which is why I supposed replace/replaceall.

    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
  • urahonkyurahonky Registered User regular
    Let's just say it's doing the trim lots and lots of times.

  • 21stCentury21stCentury Call me Pixel, or Pix for short! [They/Them]Registered User regular
    edited October 2013
    So, I decided to learn this "programming" thing and maybe try and make a game or two while I do it.

    Right now, I'm going through CodeAcademy courses on Javascript and I was wondering...

    Can you make a timer in Javascript? Because i have this idea for a game in the same vein as Candy Box and A Dark Room and i'd need to take time into account.

    Thanks in advance.

    (Learning things is exciting)

    21stCentury on
  • bowenbowen How you doin'? Registered User regular
    D:

    This is the situation where regex is the appropriate answer then. Collapsing whitespace in the middle of a string is an okay use.

    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
  • bowenbowen How you doin'? Registered User regular
    So, I decided to learn this "programming" thing and maybe try and make a game or two while I do it.

    Right now, I'm going through CodeAcademy courses on Javascript and I was wondering...

    Can you make a timer in Javascript? Because i have this idea for a game in the same vein as Candy Box and A Dark Room and i'd need to take time into account.

    Thanks in advance.

    (Learning things is exciting)

    @21stCentury

    setInterval is what you're looking for.

    https://developer.mozilla.org/en-US/docs/Web/API/Window.setInterval

    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
  • 21stCentury21stCentury Call me Pixel, or Pix for short! [They/Them]Registered User regular
    bowen wrote: »
    So, I decided to learn this "programming" thing and maybe try and make a game or two while I do it.

    Right now, I'm going through CodeAcademy courses on Javascript and I was wondering...

    Can you make a timer in Javascript? Because i have this idea for a game in the same vein as Candy Box and A Dark Room and i'd need to take time into account.

    Thanks in advance.

    (Learning things is exciting)

    setInterval is what you're looking for.

    https://developer.mozilla.org/en-US/docs/Web/API/Window.setInterval

    Cool, thanks for the quick response!

    My nefarious plot advances!

    bowen
  • NightslyrNightslyr Registered User regular
    Echo wrote: »
    Basically, if a template engine won't let me do basic shit like this, it's not for me.
    {{ Former::open()->action(URL::route('contest.store')) }}
    

    Because I like having my helper classes that spit out Bootstrapified HTML for me. I don't want to have to re-implement it by wrapping every method the helper has to make the template engine happy.

    ...what is that code block supposed to do? I use twig exclusively, and aside from form rendering (forms are a weak spot with all of Sensio's offerings), don't have any issues with it.

    PSN/XBL/Nintendo/Origin/Steam: Nightslyr 3DS: 1607-1682-2948
    Switch: SW-3515-0057-3813 FF XIV: Q'vehn Tia
  • EchoEcho ski-bap ba-dapModerator mod
    edited October 2013
    It's Former. It turns this
    Former::select('clients')->options($clients, 2)
      ->help('Pick some dude')
      ->state('warning')
    

    into this
    <div class="control-group warning">
      <label for="clients" class="control-label">Clients</label>
      <div class="controls">
        <select id="clients" name="clients">
          <option value="0">Mickael</option>
          <option value="1">Joseph</option>
          <option value="2" selected="selected">Patrick</option>
        </select>
        <span class="help-inline">Pick some dude</span>
      </div>
    </div>
    

    Echo on
  • NightslyrNightslyr Registered User regular
    Ah, yeah... twig doesn't have anything like that. Twig's really just a "Write HTML until you need to inject data, or loop, or have a conditional" template engine. Forms are definitely its weak spot.

    PSN/XBL/Nintendo/Origin/Steam: Nightslyr 3DS: 1607-1682-2948
    Switch: SW-3515-0057-3813 FF XIV: Q'vehn Tia
  • EchoEcho ski-bap ba-dapModerator mod
    Blade works fine for me so far. It's essentially just a very lightweight wrapper that turns "{{ ... }}" into "<?php ... ?>" and @if(...) for control stuff in a cached template, with some extra bells and whistles (partials and stuff) beyond that.

    This is a simple layout that calls some partials, and page-specific sub-views kick their content into the @yield('content') part.

    Also, my totally brilliant debug stuff.
    <!DOCTYPE html>
    <html lang="sv">
    <head>
      <title></title>
    @include('partial.head')
    </head>
    <body>
    
    @include('partial.nav')
    
    <div class="container">
      @include('partial.flash')
      @yield('content')
    </div>
    
    @if(false)
      <div class="container container-debug">
        @include('debug.input')
        @include('debug.session')
      </div>
    @endif
    
    @include('partial.js-footer')
    </body>
    </html>
    

  • an_altan_alt Registered User regular
    This morning I wrote my first multi-threaded program since I was in school. It's just a little script to test the concurrent performance of one of our SOAP services that does a lot of heavy lifting. It is running and such, but I'd appreciate a little feedback on how I'm doing it wrong since I'm not used to this whole threading thing.
    url_to_test = "http://example.com/poppybutts.wsdl"
    service_name = "DoStuff"
    valid_response = "<TheImportantStuff>"
    input_file = "input_filename.xml"
    attempts = 100
    
    
    class TestThread(threading.Thread):
        def __init__(self, url, service, postdata):
            threading.Thread.__init__(self)
            self.url = url
            self.service_name = service
            self.post_data = postdata
            self.running_time = 0
            self.response = ""
    
        def run(self):
            start = time.time()
            try:
                client = suds.client.Client(self.url)  # yes, the soap library is called 'suds'
                self.response = getattr(client.service, self.service_name)(self.post_data)
            except:
                pass # failure only needs to be counted, not explained
    
            self.running_time = time.time() - start
    
    if __name__ == '__main__':
    
        with open(input_file, 'r') as f:
            data_to_send = f.read()
    
        thread_list = []
        success_count = 0
        successful_time_total = 0.0
    
        start_time = time.time()
    
        for _ in range(attempts):
            current = TestThread(url_to_test, service_name, data_to_send)
            thread_list.append(current)
            current.start()
    
        for item in thread_list:
            item.join()
            if valid_response in item.response:
                success_count += 1
                successful_time_total += item.running_time
    
        print str(success_count) + " of " + str(attempts) + " attempts successful"
        print "Average successful response: " + str(round(successful_time_total / success_count, 4)) + " seconds"
        print "Total run time: " + str(round(time.time() - start_time, 2)) + " seconds"
    

    It seems to work properly in that it total running time isn't drastically higher than the average thread time for a modest number of requests. Am I doing terrible things here or is this about the right approach?

    Thanks!

    Pony wrote:
    I think that the internet has been for years on the path to creating what is essentially an electronic Necronomicon: A collection of blasphemous unrealities so perverse that to even glimpse at its contents, if but for a moment, is to irrevocably forfeit a portion of your sanity.
    Xbox - PearlBlueS0ul, Steam
    If you ever need to talk to someone, feel free to message me. Yes, that includes you.
  • urahonkyurahonky Registered User regular
    It's still running.

    I am guessing this piece of shit laptop just shit the bed because it's been at 100% CPU usage for 2 hours now. Goddamn it. Fucking multi-billion fucking dollar company and they can't fucking spend any fucking money on giving us software developers any fucking computers.

  • DehumanizedDehumanized Registered User regular
    bowen wrote: »
    So, I decided to learn this "programming" thing and maybe try and make a game or two while I do it.

    Right now, I'm going through CodeAcademy courses on Javascript and I was wondering...

    Can you make a timer in Javascript? Because i have this idea for a game in the same vein as Candy Box and A Dark Room and i'd need to take time into account.

    Thanks in advance.

    (Learning things is exciting)

    setInterval is what you're looking for.

    https://developer.mozilla.org/en-US/docs/Web/API/Window.setInterval

    Cool, thanks for the quick response!

    My nefarious plot advances!

    If you wanna check out a really cool application of JavaScript, read through the code to Cookie Clicker. It's pretty messy in places because the game is still in development, but there's some really neat game uses of the language in there.

  • bowenbowen How you doin'? Registered User regular
    It's not the computers, it's the heavy handed IT policies that impact all users, regardless of need because Dorthy, the doting 50 year old secretary, can't stop clicking forwards from grandma.
    Fr1cdyH.png

    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
  • EvilMonkeyEvilMonkey Registered User regular
    Why can't I click the clover bowen? It must be clicked!

    [PSN: SciencePiggy] [Steam]
  • 21stCentury21stCentury Call me Pixel, or Pix for short! [They/Them]Registered User regular
    bowen wrote: »
    So, I decided to learn this "programming" thing and maybe try and make a game or two while I do it.

    Right now, I'm going through CodeAcademy courses on Javascript and I was wondering...

    Can you make a timer in Javascript? Because i have this idea for a game in the same vein as Candy Box and A Dark Room and i'd need to take time into account.

    Thanks in advance.

    (Learning things is exciting)

    setInterval is what you're looking for.

    https://developer.mozilla.org/en-US/docs/Web/API/Window.setInterval

    Cool, thanks for the quick response!

    My nefarious plot advances!

    If you wanna check out a really cool application of JavaScript, read through the code to Cookie Clicker. It's pretty messy in places because the game is still in development, but there's some really neat game uses of the language in there.

    Thanks for that! I didn't think the code would be easily available like that... Dunno why. Cookie Clicker is great. :)

  • DehumanizedDehumanized Registered User regular
    The fun thing about Javascript based games is that you basically can't hide anything about how it all works.

    DelmainThe Anonymous
This discussion has been closed.