• Breaking News

    Sunday, June 30, 2019

    What the hell are workers??? Ask Programming

    What the hell are workers??? Ask Programming


    What the hell are workers???

    Posted: 30 Jun 2019 11:37 AM PDT

    I've been doing web development for a little while, mostly with django. I've been starting to understand gunicorn, and nginx as well, so I can see how it all works, but I keep seeing the word worker, and I don't really get what that is..

    I'll hear someone mention that their server is running 3 workers. What does that mean? What are they doing? Why only 3? How do I make more? (Maybe they're little people in my hdd?)

    Really any insight on what they are, what it means, and how it works would be hugely appreciated, thank you! <3

    submitted by /u/Ecocide113
    [link] [comments]

    What’s needed to make a Program closing on pressing X in tabbed mode

    Posted: 30 Jun 2019 08:57 PM PDT

    I want to write a program that sends WM_QUERYENDSESSION to a program when I click on the X on it on it in tabbed out mode. Like the stronger closing thing when you press sign out, since a lot of programs are annoying like Skype and or just stop responding and I wanna close them on command, not go thru task manager which may not work bc it's an unresponsive full screen program.

    I know a little C, which I think windows is written in, and I can compile a program in C on eclipse

    So is it possible to code this into a program on my machine? In what language if not C?

    submitted by /u/aronkra
    [link] [comments]

    OpenGL ~4.3, trying to get 2 outputs from one fragment shader.

    Posted: 30 Jun 2019 02:08 PM PDT

    https://pastebin.com/LsMsYsfG

    out vec4 fragOut, secondaryOut; in vec2 texCoordsForwarded; uniform float ratio, scale; uniform sampler2D tex0,tex1; void main() { secondaryOut = vec4(0.5 *( 1.0+ vec3(sin(scale), sin(scale + 2.0943951) , sin(scale+4.1887902))), 1.0); fragOut = mix( texture(tex1, texCoordsForwarded), texture(tex0, texCoordsForwarded), ratio); } in vec3 vertexPos; in vec2 texCoords; out vec2 texCoordsForwarded; uniform mat4 view, projection; void main() { texCoordsForwarded = texCoords; gl_Position = projection * view * vec4(vertexPos, 1.0); } 

    tried making a new FBO and attaching a new renderbuffer to it, but it wouldn't display on screen.

    tried attaching a new renderbuffer to the default framebuffer, it reads black from colorAttachment1

    if anyone takes a look at it, let me know

    you'll need c# 7.3, glm-net, opengl-net and glfw-net if you plan on compiling them

    and a couple of png in ..\data\ relative to the binary

    submitted by /u/MasochistCoder
    [link] [comments]

    What are concurrent builds?

    Posted: 30 Jun 2019 07:17 PM PDT

    I can't find an answer on Google so I'm guessing this is a dumb question. On Netlify's paid plan it says "concurrent builds". Does this mean I can only have three static websites?

    https://www.netlify.com/pricing/

    submitted by /u/wearethemartian
    [link] [comments]

    Python Help

    Posted: 30 Jun 2019 07:06 PM PDT

    I'm currently working on a code for a class that is requiring us to make a picture "collage" using JES or a java version of python, but having difficulty getting the code to work. this is what I have so far. However, I keep getting an error relating to having 3 arguments in the getPixels() function. The professor said it should work but it seems that either i'm not understanding it or that he made a mistake. But either way I could really use some help on fixing the issue.

    def combineImage():

    mystical = makePicture(pickAFile())

    man = makePicture(pickAFile())

    animalHeight = getHeight(mystical)

    animalWidth = getWidth(mystical)

    manHeight = getHeight(man)

    manWidth = getWidth(man)

    newHeight = manHeight + animalHeight

    newWidth = manWidth + animalWidth

    mysticalPx = getPixels(mystical)

    manPx = getPixels(man)

    collagePicture = makeEmptyPicture(newHeight,newWidth)

    collagePx = getPixels(collagePicture)

    for index in mysticalPx:

    newColor = getColor(index)

    xPosition = getX(index)

    yPosition = getY(index)

    canvasPx = getPixels(collagePicture, xPosition, yPosition)

    setColor(canvasPx, newColor)

    xBuffer = xPosition

    for index in manPx:

    newColor = getColor(manPx[index])

    xPosition = getX(manPx[index])

    yPosition = getY(manPx[index])

    newXPosition = xBuffer + xPosition

    canvasPx = getPixels(collagePicture, newXPosition, yPosition)

    setColor(canvasPx, newColor)

    saveAs = pickAFile()

    writePictureTo(mythical,saveAs)

    show(mythical)

    submitted by /u/darthleaf45
    [link] [comments]

    C++: Safely removing an element from a collection of pointers

    Posted: 30 Jun 2019 01:52 PM PDT

    Hi, in a game I am coding I have a OrderManager class that manages objects of type OrderForPlayer. The OrderManager contains a data structure that holds pointers to OrderForPlayer objects. The data structure is currently a vector but please advice if there is a more appropriate choice for what I am trying to do.

    I have a DeleteOrder function that takes a OrderForPlayer pointer as reference, and performs an operation to remove that pointer from the manager's collection and delete it.

    void DeleteOrder(OrderForPlayer*& order) { order->CleanUp(); order_collection_.erase(std::remove(order_collection_.begin(), order_collection_.end(), order), order_collection_.end()); delete order; order = NULL; } 

    Currently, a new order is created every 4 seconds, and each order is deleted after it has been "alive" for 20 seconds. This means that there should be at most 5 orders active at any time. What I am seeing however is strange behaviour - with the order_collection_ forever growing in size when referring to the .size()function, and both the OrderForPlayer pointer sent to be deleted and the one adjacent to it in the vector no longer being seen as valid by other functions.

    Update function called in OrderManager every frame in the game loop

    void UpdateOrders(float frame_time) { for (auto*& o : order_collection_) { if (o) { o->Update(frame_time); if (timer_depleted(o)) { DeleteOrder(o); } } } } 

    timer_depleted

    bool timer_depleted(OrderForPlayer*& order) { if (order->GetTimeRemaining() <= 0.0f) return true; else return false; } 

    Function called in Game object. The Game object holds the OrderManager. It is through this function that I can see the order collection is not behaving correctly.

    void Game::DrawHUD() { auto& order_collection = order_manager_.GetOrderCollection(); int i = 0; for (auto*& o : order_collection) { if (o) { float x = (float)i * 72.0f; o->SetPosition(gef::Vector4(x, o->GetPosition().y(), o->GetPosition().z())); sprite_renderer_->DrawSprite(o->GetProgressBarSprite()); sprite_renderer_->DrawSprite(o->GetSymbolSprite()); ++i; } } } 

    Please note that without the if (o) checks to see if the pointer is valid, the program crashes, although as far as I know it should not as the order collection should only be containing valid pointers anyway. I believe the problem lies in DeleteOrder, but I have used the same style of .erase() call before and it has worked perfectly.

    Thanks very much for reading!

    submitted by /u/WilliamWallace2K14
    [link] [comments]

    What are common problems in modern web development?

    Posted: 30 Jun 2019 03:38 AM PDT

    I've got team of 3 programmers and myself as designer. We all are at that point of learning, when you want to create a product, that will solve someone's problem, and add it to your portfolio. With no or little profit, of course. The problem is, this is our first serious project, so we want to make something really useful. But we're running out of ideas. So I'd be really grateful if you write anything that annoys you or share ideas for useful tools, that should, but don't exist for web development

    submitted by /u/JayTeeJee781
    [link] [comments]

    Is it possible to automate a task like cancelling a cell phone plan and signing up for a new one every month?

    Posted: 30 Jun 2019 04:13 PM PDT

    CSS Column and Button Questions

    Posted: 30 Jun 2019 03:19 PM PDT

    https://prnt.sc/o8rqgn

    https://prnt.sc/o8rqmn

    The first questions is I am trying to make the text boxes and save buttons all on the same line. Like how do I make the column wider?

    The second question is about how I can make the text in the buttons centered vertically and horizontally.

    submitted by /u/Yolobone
    [link] [comments]

    What are easily, python 3 or js (with node.js)?

    Posted: 30 Jun 2019 06:32 PM PDT

    Squarespace: form submission failure: After successfully processing form data with JavaScript, the form doesn't submit to Mailchimp

    Posted: 30 Jun 2019 12:23 PM PDT

    This post may be too narrow in scope or too simple for this forum. If true, I apologize.

    I have a form in a Squarespace form block. I successfully intercept the form before submission (using a form.submit()
    listener) and successfully read and process the data. I only read the form data (Array.from($('select'))). I don't interfere with the form structure or the submission process other than to intercept it before submission. e.preventDefault()
    is not set.

    The JavaScript successfully executes. It submits table update data to an Amazon Web Services table. AWS sends logs to the console acknowledging success. I let the JavaScript terminate upon success. I have tried a form.submit()
    call at the end, but it has no effect.

    There are no error messages.

    The really curious, anomalous behavior is that I've tested it and found that of the five tests, two (the first and third) succeeded in updating my MailChimp list while three did not. For those three, I received a Squarespace email notice of form submission failure. It gives no error message other than to say the submission to MailChimp failed.

    However, when I made the connection to an email address, the submission succeeded every time. I got an email notice of the submission. It's just when the form storage is MailChimp that the submission fails (sometimes).

    I disconnected the MailChimp list from the form in the Squarespace form storage dialog. I removed Squarespace from the list of approved applications on Mailchimp I reconnected storage to my Mailchimp list and tested it again. The submission failed.

    You can find the form on this page. All the JavaScript can be found on this page. I'm reluctant to put it here because I don't want to burden the question with it.

    If someone can give me guidance as to why this occurs and how to fix it, I'd sure be grateful. In fact, I'm grateful that you've read this far whether or not you can help. Thanks.

    submitted by /u/alxfyv
    [link] [comments]

    [x86, SIMD] Optimization of mixer/resampler for waveform-based synthesis

    Posted: 30 Jun 2019 11:30 AM PDT

    Sorry in advance if Intel syntax hurts. <_< I was 'raised' in ARM assembly, so that syntax seems the most natural to me. Also this is probably too specialized for /r/AskProgramming (who codes in actual ASM nowadays?), but I thought I'd give it a shot.

    I've been working on writing the main 'mixing core' for a waveform-based synth (think something along the lines of the MS Wavetable Synthesizer on Windows). I decided to write it in ASM just because it seemed fun, and I'd done something similar on an ARM9 processor (for the record, I tried letting the compiler handle it, using intrinsics; it pretty much spat out the code I wrote up verbatim (which makes sense, of course), just with more stack usage).

    Anyway, the problem I ran into is that the vector code is very serialized, and I'm not quite sure that there's a way around it. So I thought I'd ask here in case anyone has any ideas (even if it involves changing the implementation altogether).

    The basic idea of what the code does is to resample a source signal (using a simple 4-tap FIR filter), and mix it to an output buffer with amplitude scaling:

    for(i=0;i<N;i++) { // Position is 16.16 fixed-point IntPosition = Position >> 16 SubPosition = Position & 0xFFFF // Use 4-tap filter to get interpolated samples // Input[] and the FIR window are int16_t, so in practice this // uses PMADDWD to get a [scaled] int32_t SampleL = FIRWindow(&Input[IntPosition*2+0], SubPosition) SampleR = FIRWindow(&Input[IntPosition*2+1], SubPosition) // Mix to output buffer // Output[] and VolumeL/R are float *Output++ += SampleL*VolumeL *Output++ += SampleR*VolumeR // Update position and volume Position += Rate VolumeL += RampL VolumeR += RampR } 

    The FIR coefficients table is 4KiB (1/256 positional accuracy), so I don't think it's too much of a problem to perform random-ish access on it. I can get it down to 2KiB if absolutely needed, but that would need unpacking in the actual code.


    Okay, so now, the ASM code.

    First, a list of register allocations:

    eax: Position [unsigned 16.16] ebx: Rate [unsigned 16.16] ecx: RemN (basically: N/2 in the 'body' loop) edx: [Temp] esi: &WaveData (input; int16_t[][NumberOfChannels]) edi: &WaveBuffer (output; float[][2]) ebp: &Window (int16_t[][2][4]) xmm0: [Temp] xmm1: [Temp] xmm2: {VolCur[2], VolCur[2]+VolStp[2]} (float; L/R) xmm3: {VolStp[2], VolStp[2]} (float; L/R) xmm4: ShuffleMask esp+00h: N 
    • VolCur and VolStp are placed like that because the 'body' loop mixes two samples at once (and xmm3 is doubled when entering there); not too important for this.
    • xmm4 contains a mask for PSHUFB to de-interleave stereo data from {L0,R0,L1,R1,L2,R2,L3,R3} into {L0,L1,L2,L3,R0,R1,R2,R3}.
    • The window has four 16-bit coefficients {a,b,c,d}. In practice, they're doubled-up for stereo ({a,b,c,d,a,b,c,d}) to do it with a single memory-addressed PMADDWD instead of having to MOVQ,PUNPCKLQDQ,PMADDWD with a temporary register.

    Because the mixer is intended to handle mono and [interleaved] stereo signals, there's two variants of the mixing functions with practically identical code. Because of that, I implemented everything in macros.

    The first macro fetches the filtered L/R sample:

    .macro FetchSmp1 Dst MOV edx, eax /* int(Position) -> edx */ SHR edx, 16 MOVQ \Dst, [esi + edx*2] /* Smp -> Dst */ MOVZX edx, ah /* Phase[.8]*0x10 -> edx */ SHL edx, 4 PUNPCKLQDQ \Dst, \Dst /* Copy 'left' to 'right' */ PMADDWD \Dst, [edx + ebp] /* Smp *= Win {La,Lb,Ra,Rb} */ ADD eax, ebx /* Position += Rate */ .endm .macro FetchSmp2 Dst, nCh MOV edx, eax /* int(Position) -> edx */ SHR edx, 16 MOVDQU \Dst, [esi + edx*4] /* Smp -> Dst */ MOVZX edx, ah /* Phase[.8]*0x10 -> edx */ SHL edx, 4 PSHUFB \Dst, xmm4 /* De-interleave left/right */ PMADDWD \Dst, [edx + ebp] /* Smp *= Win {La,Lb,Ra,Rb} */ ADD eax, ebx /* Position += Rate */ .endm 

    Pretty average stuff (with a slight caveat: Dst needs a two-element horizontal add). The only 'trick' is MOVZX edx, ah; SHL edx, 4: the FIR coefficients table has a 1/256 precision, so I just extract the high 8-bits of the fractional position instead of shifting/masking my way there manually.

    The output buffer is expected to be properly aligned when allocated (16-byte or whatever), but mixing may be interrupted at any point (for example, to restart a loop), which misaligns it on an odd number of samples. So the mixer handles the 'head' sample to align it, mixes the 'body' two output samples at a time, and handles the 'tail' sample as needed. Since the code is practically the same as the 'body', I'll focus on that.

    The loop goes as:

    1: FetchSmp xmm0 FetchSmp xmm1 PHADDD xmm0, xmm1 /* {L0,R0,L1,R1} */ MOVAPS xmm1, [edi] /* Fetch output samples */ CVTDQ2PS xmm0, xmm0 /* Cast to float */ ADD edi, 0x10 /* [Advance buffer] */ DEC ecx /* [--RemN?] */ MULPS xmm0, xmm2 /* MixSmp *= VolCur */ ADDPS xmm2, xmm3 /* VolCur += VolStp */ ADDPS xmm1, xmm0 /* Mix to output */ MOVAPS [edi - 0x10], xmm1 JNZ 1b 

    Nothing earth-shattering here, either. I tried to do some instruction scheduling that hopefully is friendly to most CPUs (even though I doubt it matters much these days with out-of-order execution), but otherwise it's fairly vanilla.


    Alright, so the problem. I haven't tested this code in any way, and pretty much just wrote it for fun. However, I can still clearly see that the vector code is really, really serialized. Given that, I was wondering if anyone has any pointers on what I could do to try and reduce some of that load? Perhaps getting rid of the dependence on PSHUFB and PHADDD?

    Pretty much the only idea I can come up with is to interleave the samples fetching, but if SIMD instructions are just 'queued up', then that would probably make no difference since the vector registers for that don't rely on one another.

    Cheers for making it this far, and in advance for any help!

    submitted by /u/Aikku93
    [link] [comments]

    Changing an XML document programatically in c#

    Posted: 30 Jun 2019 06:22 AM PDT

    I have an app where im saving data in an XML file (dont ask, its mostly for learning but it has to be XML file). Each important type has its own file as a repository for that type.

    The way i add items to simple load everything in, deserialise it to objects, add the new object to the list, serialise everything and overwrite the older file.

    Im starting to think about performance. Would i gain anything by insteas reading the file as a text file and modify and then save it? My guess is actuall that i wouldnt cause it still means the old file will be overwritten by a new updated version am i right?

    submitted by /u/NinRejper
    [link] [comments]

    Switching career path, need advice

    Posted: 30 Jun 2019 09:54 AM PDT

    Hello, guys!

    I'm a bit at a crossroads now and was hoping to get some other perspectives and advice. Currently I am employed as a software developer (web-backend) and looking for some change in the career path. But let's start from the beginning.

    As a child I was fond of PC-games like so many others, but it wasn't until years at the university (getting general engineering degree) that I rediscovered my interest in CS. My friend and I were making an online game just for the fun of it. Then got into MCU programming, which then led to taking several online courses on coursera. This allowed me to find a job in a state research center. It was really interesting and I had an opportunity to work with OpenGL and CUDA, we made programs for scientific calculations so I felt like I was doing something useful, I had to invent algorithms and use my math knowledge as well which felt really fulfilling. But I had to leave this job because of very low salary (like really low) and necessity to take secrecy access that would ban me from leaving the country. After that I was involved into a start-up with a friend up until I found a "real" job in CCTV-field. I was expecting some image processing tasks and using of computer vision algorithms nut it turned out to be fixing casual bugs in legacy and doing some web-development.

    In the meantime I kept learning about different fields of CS, from the most fundamental ones to some of the more specific. In particular, at the beginning I was vey interested in ML (especially after watching Andrew Ng Stanford course on youtube), however practice made me realize it's not about cool math and real science nowadays but mostly about fighting with datasets and python frameworks (which resulted in deep python dislike). One of the courses that I've taken - Golang webDev - got me a job at one of the main Russian IT corporations, and as I stated at the beginning it is basically backend web-development. I don't really like web-development, but I think highload problems can be fun (especially optimizations), and I really love Golang.

    I spent last half-year to try to learn some hardcore math (topology, category theory etc.) - not great results, because it required much more time than I had, but I really enjoyed it nonetheless. Learned functional programming with Haskell - just loved it. I tried to learn computer graphics as well: watched UC Davis Academics course "Introduction to Computer Graphics", tried messing up with OpenGL (ended up with a lot of textured crates, flying camera and basic lighting). Tried to learn Vulkan API as well. And then basically I've stuck. It feels like interesting stuff to do, but every time I read a tutorial or a forum I feel like a total noob, that just doesn't get some basics and can't do anything. I also helped my wife with image proccessing project and it was pretty fun. Reading the white paper, understanding it's math and implementing it to work was just awesome (but again python and numpy - hate them).

    We are also moving to Canada next year, but I don't want to continue the current career path and I think in a way it is a great timing to change it. Maybe try game development, but to do graphics in AAA-titels you should be experienced professional but in order to become such you've got to be a mobile games developer for years, or be doing some other routine which does not excite me at all. Haskell might also be an option but it seems that my interest would also vanish if I'd have to do some boring tasks.

    So what I am trying to say is that for some reason I am tired and washed out. I think I would like to be that guy, who uses math and create some useful scientific software or making game-engine with ray-tracing and other state-of-art ideas, but I just don't know how to move into that directions. Meanwhile I try to work as hard as I can on my current position but I still feel like shit and I don't believe it should be this way.

    If you've been through such a period in your career I would very much appreciate your stories. Any advice are very much welcome. Also if you know some other sub which would be appropriate to post this, feel free to mention it.

    submitted by /u/AngryRussianPostman
    [link] [comments]

    Use Azure to host a restful API and database

    Posted: 30 Jun 2019 01:01 AM PDT

    I want to use Azure for a project i'm working on, and I can't find a tutorial that helps me out with what i'm looking for. I want to host a RESTful API, as well as a web app, and a database on Azure. I think I have the database hooked up, but i'm not sure how I can get the REST API hooked up, or what resource to use for it, or how I would link it with the database. I have looked through Microsoft's tutorials, and i'm not sure which one I should follow. Any Suggestions?

    submitted by /u/littlepigboy5
    [link] [comments]

    No comments:

    Post a Comment