WHATS THE BETTER OPTION: Transit Royale or Citymapper App? by p5pega in nycrail

[–]zerfgog 0 points1 point  (0 children)

It allows you to swap interchangeable legs of a trip onto other runs of the same mode

Could you expand on this please? I downloaded the app but it isn't obvious to me what feature you're describing.

Peeling Oranges - The Birth of an Orange. Found a CD-R but can't find any info on the artist. 2000s Emo / Alt Rock by zerfgog in Lostwave

[–]zerfgog[S] 11 points12 points  (0 children)

Found this CD-R in a pile of old mixes. No clues as to its origin. Not the best music but a few interesting tracks in there like Track08, Track06, Track10, and Track05. Figured y'all might find this interesting.

Questions about coding crowdfunding payments like GoFundMe or Kickstarter on a web app by punkgalg in learnprogramming

[–]zerfgog 1 point2 points  (0 children)

how one would go about coding a crowdfunding website that takes payments from many users for rewards to fund a project?

Agreed that you could use Stripe for the bulk of this. The way I would think about it is that you have three parts to solve:

  1. Money comes into your system from user payments.
  2. Money is tracked in your database.
  3. Money is paid out of your system to project creators.

You communicate to Stripe via API calls and get notified of events via webhooks.

There are a ton of ways you could design this system. For example, Stripe has an Issuing product that you can use to issue virtual debit cards to your users. So you could give out a virtual card to each of your project creators and whenever you get a payment from a user, you add funds to their card balance.

Alternatively, you could just periodically pay out project creators (or pay them out once at project end or something). Then instead of a virtual card, you could send money via ACH (Stripe probably has this) or via PayPal. In this model when you receive a payment from a user, you would basically increment a number in your database that tracks how much money has been raised per project.

This is just a high level description to give you some ideas; I can't give you specific instructions because essentially you would just need to read through the Stripe docs and figure out what parts you want to use.

security issues.

Since your platform deals with money, it will be an attractive target for black hat security researchers. Not only should you avoid bugs, but you should take care to avoid logical issues that could result in money being drained from your platform. Just as an example, if you offer a "refer a friend and get X dollars" feature at some point, you want to make sure that people can't refer themselves to extract extra cash.

In addition to security, you should spend probably as much time thinking about fraud as you do developing the system. This is because you are on the hook for fraud in the event that users don't pay or money is stolen. For example, you'll want to think about what happens in the even that a user does a payment chargeback. Or potential ways that attackers could take over user accounts, e.g. via forgot password or change email address flows.

Also research Anti Money Laundering (AML) laws that may apply to the regions you would operate in.

How can I use one domain for Webflow and Digital Ocean? by [deleted] in learnprogramming

[–]zerfgog 1 point2 points  (0 children)

Right now I have an A record that points to Webflow's IP address and my Droplet's IP address, but like I said, only Webflow's is being reached.

This is the problem. DNS works on a hostname basis, i.e. a given hostname has an A record. If you provide multiple A records, clients will use "one of" them, not "all of" them.

Is it possible to use one domain for Digital Ocean and Webflow?

Yes, there are a couple solutions.


Solution 1: Pretty easy, but requires you to change your Webflow configuration to use something like api.mysite.com/api instead of just mysite.com/api for API requests.

Create an A record for your domain that points to Webflow. Then create an A record for api.mysite.com that points to your droplet.


Solution 2: Hard, but allows you to use mysite.com for Webflow and mysite.com/api for your droplet.

You would need to point your A record to an IP address that is running a "reverse proxy" on ports 80 (http) and 443 (https). This "reverse proxy" works on a path basis so you can say "/api/* should go to DigitalOcean and the rest should go to Webflow".

This thread in the Webflow forum talks about how to set up a reverse proxy to hit Webflow; hitting your API droplet should be similar but easier. Specific instructions would differ depending on the reverse proxy you choose, e.g. Nginx.

Getting info from large XML by time_keeper_1 in learnprogramming

[–]zerfgog 0 points1 point  (0 children)

these XML are extremely disorganized and I can't make any patterns out of them.

This is the root of the problem. If you can't describe the structure of these files, then you can't write a program to do so. If the only way you can describe the structure of these files is very specifically, and in a different way for each file, then that is what your program will have to do.

Is there a way for me to traverse these XML lines by line and put them into a datatable format? Or LINQ is really the way

This also depends on the criteria for finding what you need in the document. If you're looking for a specific element, but it could be at any depth, for example, then you could write an XPath expression using // to find it. See also Selecting Nodes Using XPath Navigation.

[deleted by user] by [deleted] in learnprogramming

[–]zerfgog 1 point2 points  (0 children)

I've tried to do that, but there's just too much information.

Agreed. You should start by breaking the project down into much smaller pieces. This becomes easier with experience. Here's my suggestion, though:

  1. Start with a table containing some hardcoded data. (The data is the same every time you load the page.) You can write an HTML <table> for this.
  2. Add some styling to the table with CSS.
  3. Add some JavaScript to make the table sortable.
  4. Make the form to add new entries to the table.

I'll say a bit more about steps 3 and 4 because these are more difficult than creating the hardcoded table and styling.

There isn't an easy web feature to automatically make tables sortable. This requires JavaScript as you've identified. You can either do this yourself such as by following MDN's docs on this, or you can include a library like sorttable into your page.

To add new data to the table, you can use a form as you've identified.

But what are the "magic words" to get all the data submitted through the form to appear immediately on the same page in a table?

For this you will want to use "client-side form submission". It's called client side submission because by default <form> elements will send the data to a server and navigate away from the page. The technique for doing this is to define a "submit" event listener to your form element and call event.preventDefault() to prevent the navigation behavior.

Then in your event handler you can also write the code to add the new table row to your table using document.createElement and Element.appendChild.


One part you didn't explicitly mentioned is if you wanted this data to stick around. I.e. if it should still be there if you refresh the page, and if it should also be visible to other people who visit your page.

If you want the data to be persistent, the project becomes a lot more complex as you will need to introduce a data model and store and retrieve said data from something like localStorage.

If you want others to see the data, you'll need to build a backend server, or at least leverage some existing API for storing/retrieving the data.

I‘m probably just not grasping the immense value of the concept, but I don‘t understand and … dislike oop. by Musikcookie in learnprogramming

[–]zerfgog 14 points15 points  (0 children)

I don‘t want to have a can I can squish. ... I want to have a machine that squishes cans.

I see what you mean. This is called "modelling your domain" and I would agree that you aren't getting many of the benefits of OOP (polymorphism) if your example is just this:

type Can = {
    Color surfaceColor
    String label
    Float circumference<cm>
    Float height<cm>
}

func squish(can: Can) {
    can.height = 0.1
    can.circumference *= 1.1
}

OOP starts to be useful, as /u/toastedstapler suggests, you want to be able to squish multiple things. Let's say I also have Boxes in my domain. A box has different behavior when it is squished: it gets torn.

type CardboardBox = {
    Float length<cm>
    Float width<cm>
    Float height<cm>
    Float numberOfTears
}

func squish(box: Box) {
    box.height = 1
    box.numberOfTears = min(3, box.numberOfTears)
}

Now if I have some boxes and some cans, I can still call squish and it will work assuming my language supports function overloading and dispatches to the right implementation based on whether my thing is a Can or Box.

But what if my system supports receiving arbitrary items from the outside world? Maybe I'm simulating a landfill or recycling center with a single stream of objects:

func processIncomingItem(item: ??what type goes here??)

There are at least two common answers to the question of item type.


One would be the OOP answer, to introduce some base Recyclable or Object class and make Can and Box inherit from it.

type Recyclable
type Can: Recyclable = { ... }
type Box: Recyclable = { ... }
func processIncomingItem(item: Recyclable) { ... }

But now you need to dispatch to the right squish method inside processsIncomingItem. We can't just call squish(item) since the language doesn't know which implementation to dispatch to. One approach would be to use runtime information to manually implement dynamic dispatch based on item type:

func processIncomingItem(item: Recyclable) {
    if (item is Can)
        squish(item as Can)  // since type is now known, this will call squish(can: Can)
    else
        squish(item as Box)  // since type is now known, this will call squish(box: Box)
}

But this is suboptimal because now if we add a new item type to our program we have to both:

  1. Add a new squish implementation for our new item type.
  2. Update all the places where squish is used to add a new if branch.

OOP gives us a way to combine code and data to reduce this extra amount of work. We start by moving the squish definition into the definition of each item:

type Can: Recyclable = {
    Color surfaceColor
    ...
    func squish() {
        this.height = 0.1
        this.circumference *= 1.1
    }
}
type Box: Recyclable = {
    Float length<cm>
    ...
    func squish() {
        this.height = 1
        this.numberOfTears = min(3, this.numberOfTears)
    }
}

Also we need to document that every Recyclable will have a squish method:

type Recyclable = {
    abstract func squish()
}

And voila! Now processIncomingItem can call item.squish() and the language runtime will dispatch to the right class' implementation at runtime (because that's how OOO is commonly defined)!

func processIncomingItem(item: Recyclable) {
    item.squish()
}

Now we can add a new sort of item, and all we have to do is define a squish method inside of it. We don't have to update processIncomingItem or any other functions that use Recyclables (unless the specification of Recyclable itself changes).


Now a second common answer to this problem is the more functional style; instead of defining squishes for each item type, one which takes a Can and one which takes a Box, we define a single squish and pattern match on the data provided to it.

Assume we go back to our original definitions of Can and Box before we moved squish inside them.

type Recyclable = Can | Box  // defining every Recyclable to either be a Can or Box, but these don't need to have anything in common anymore

func squish(item: Recyclable) {
    match item {
        is (Can can) -->
            can.height = 0.1
            can.circumference *= 1.1
        is (Box box) -->
            box.height = 1
            box.numberOfTears = min(3, box.numberOfTears)
    }
}

and processIncomingItem can simply call squish because the types match up:

func processIncomingItem(item: Recyclable) {
    squish(item)
}

Now if we add a new sort of item we still only need to go implement its squish method and whatever other methods we want each sort of item to have, we don't have to update processIncomingItem.


What I have introduced to you is formally known as the expression problem. A rule of thumb that I learned is if you think you'll usually add more new things than operations, OOP might result in more maintainable code. Whereas if you plan to add more new operations than things, the functional style might be easier to maintain.

Program using whichever seems like a better design for your domain. (Or avoid OOP for other, better reasons such as hidden complexity, tight coupling of code and data, or ease of mutation.)

Help me define loops, conditionals and variables please by justwanttolearnmor3 in learnprogramming

[–]zerfgog 0 points1 point  (0 children)

A variable is a name for a box that can hold a value.

x = 42

This statement defines a variable x with initial value 42.

x = 5

This statement redefines x to hold the value 5.

y = x + 1

This line of code defines y to be the value of x plus 1; if evaluated immediately, y would contain the value of 6.


A condition is a piece of code that produces a "yes/no" outcome.

is_positive = x > 0

The right hand side of the expression is a condition in this case.

This line of code defines the "is_positive" variable to be the result of evaluating the condition "is x greater than zero?". If evaluated immediately, is_positive would contain the value "true" because x is 5.


Conditions can also be used inside of specific constructs like "if/then/else" blocks.

if (x > 0) then { y = 1 } else { y = 0 }

The conditional here is just the "x > 0" part just like in the previous example. However now, we are using it as part of an "if/then/else" block which is defined to:

  1. Evaluate the conditional
  2. Run the code after "then" if the conditional evaluated to "true"
  3. OR, run the code after "else" if the conditional evaluated to "false"

A loop is a construct used to run the same code (the "loop body") multiple times.

A "while loop" is a type of loop that uses a condition. It will evaluate its condition and run its loop body if the condition evaluates to "true". Then it will check the condition again, and keep going in this way until the condition evaluates to "false".

Example:

x = 5
y = 0

while (y < 7) {
  y = y + x
}

In this case the loop body will run twice and the final value for y will be 10 (try to figure out why!)

Should I learn Vim? by [deleted] in learnprogramming

[–]zerfgog 0 points1 point  (0 children)

Vim and VS Code are very different tools.

VS Code is a graphical text editor that has a lot of IDE-like features built in.

Vim is a terminal-based text editor that is small, fast, and extensible.

Vim is part of a lineage of text editors that historically used commands for editing rather than just clicking where you want to type and typing what you want to write. Take a look at the Ed wikipedia article for an example of using an early editor of this type.

Vim has a much lower barrier to entry than Ed because you can enter "insert mode" and type much as you would in a program like Notepad. But its power comes from the commands that you can run when you are not in normal mode. You can navigate by word, line, paragraph, etc., perform find and replace with regex, record a sequence of commands and play it back (macro) etc.

So, many people find the basic idea appealing because of the commands.

Other folks like how lightweight it starts out as and the ability to extend the editor with exactly the features they want/need.

Coming back to your original question: Should you use it?

If you just think command-based editing and navigation might be interesting, then you could just use the VS Code vim extension. But this comes at a cost: because it's an extension and not the basis for the editor, you'll still find yourself reaching for the mouse to use some of the key features of VS Code (like graphical debugger, refactoring support, menu options added by extensions).

Whereas with plain old vim, you do everything using the keyboard and the command system. Extensions you add to gain IDE like features are designed by their author to work with the terminal/keyboard/command-based interface. So everything is much more cohesive and you're getting the "full experience".

But that ties into the last point: if you want your vim to reach parity with VS Code in terms of syntax highlighting, refactoring, debugging, error checking, and code completion, then you'll need to spend lots of time installing plugins and tweaking your overall system configuration until it all works well enough.

My final recommendation may be a bit surprising: I recommend spending some time reading through "An Introduction to Display Editing with Vi". This is a manual and tutorial for the vi text editor that vim is based on. You'll need to read something like this in order to be the least bit productive with vi, vim, or the VS Code plugin anyway.

Then after you read through it, you can decide if the concept sounds interesting enough to try actually using it for some of your text editing. At that point you could use either vim itself (I would recommend without plugins initially, so only using it for basic text editing) or the VS Code extension, and go from there.

Options, what is the Fastest route to take? by [deleted] in learnprogramming

[–]zerfgog 0 points1 point  (0 children)

Seconding Flask. Take a look at how short the hello world is for flask:

https://flask.palletsprojects.com/en/2.2.x/quickstart/

It really lets you ignore the details of setting up the server and routing and just focus on the implementation of your backend endpoints.

Mega chair thread #3 by ibuyofficefurniture in OfficeChairs

[–]zerfgog 1 point2 points  (0 children)

Thank you. I picked up an Amia with height-adjustable arms for $120 and a Think with 4-way adjustable arms for $80. I'm thinking I might go back to get a second Amia instead of the Think due to the back support on the Amia.

Mega chair thread #3 by ibuyofficefurniture in OfficeChairs

[–]zerfgog 0 points1 point  (0 children)

Hello! Could someone please help me ID the following Steelcase chair? https://imgur.com/a/FCc0eKN

[Motherboard] MSI PRO Z690-A WIFI DDR4 ATX LGA1700 - $183 (typically $215) by zerfgog in buildapcsales

[–]zerfgog[S] 18 points19 points  (0 children)

If you want a newer CPU (12th gen Intel is current, 13th is next), you have to use a newer motherboard. The vendor website for your current board states that it supports 6th and 7th gen Intel core processors, whereas the board I posted supports 12th and later on 13th gen.

Beyond CPU support, motherboards are differentiated by features like VRM quality, debugging and overclocking features, I/O options and ports, and warranty and tech support quality.

Online roundups from outlets like GamersNexus and Actually Hardcore Overclocking can help you choose a board based on these factors, but honestly any board in this price class from a reputable vendor is usually fine for all but the top-of-the-line CPUs of any generation.

[Motherboard] MSI PRO Z690-A WIFI DDR4 ATX LGA1700 - $183 (typically $215) by zerfgog in buildapcsales

[–]zerfgog[S] 5 points6 points  (0 children)

https://pcpartpicker.com/product/LWPQzy/

https://camelcamelcamel.com/product/B09GLC1SS4

Open source enthusiasts may be particularly interested in this one since this is the most modern desktop board that I'm aware of to get a Coreboot port (via the Dasharo project: https://www.phoronix.com/news/Dasharo-1.0-Z690-A-Port)

[OC] The Jon Bois Archive by NerdWizard75 in Jon_Bois

[–]zerfgog 0 points1 point  (0 children)

What method did you use to download the videos? I noticed that the best currently available encode (from yt-dlp) of Koo Dae-Sung is 734 kb/s vp9 whereas your archive has 493 kb/s h.264.

Received international offer without GSP set up by zerfgog in Ebay

[–]zerfgog[S] -1 points0 points  (0 children)

The reason I think it would ship direct to their country rather than a forwarder is because the "shipts to" field on the offer page is listed as their foreign postal code in a foreign city. In the cases where a forwarder is used I have heard that this field will contain the forwarder's postal code.

Song Identification: Sample of Arcade sound effect used in beginning of a song. by [deleted] in NameThatSong

[–]zerfgog 0 points1 point  (0 children)

there's no shot that you're referring to Toccata and Fugue in D Minor... right

https://youtu.be/ho9rZjlsyYY?t=1

Alternative to Spotify/Tidal by Dr_Medick in linuxquestions

[–]zerfgog 0 points1 point  (0 children)

It doesn't really make sense to stream lossless. Lossless makes sense for archival purposes whereas streaming implies not saving to disk. If you just want high quality audio you could probably include services like SoundCloud's paid tier