Programming

Hah correct, and +x is what I typed into the console. I don’t use linux often, so I usually have to google this stuff again every time I do it unless I can just hit the up arrow.

sounds like you have the -dev or -devel package of the library for the compilation, but the shared lib isn’t installed on the system. static linking fixes it obv.

I just can’t imagine wanting to put typescript into the mix if you’re just writing hacker scripts for yourself.

5 years of running an industrial-sized node app in production and I can’t think of one time we had a run-time error for something that type safety would have caught at compile time. Have you run into these kinds of errors? If so I’d be interested to see one.

1 Like

Makes sense, especially when the lib comes in TS. Our big node app was built before most 3rd party libs came in TS.

The one killer app that for sure TS would have helped is the npm package I wrote that was shared by a few apps had a base object (representing an API endpoint) that then got extended by an internal shared lib and finally the app. Each layer added optional fields that could be either missing or have values. There was no way to point to one file that devs could go to see all the possible options for their endpoints. TS would have helped that.

But there were so many other things that not having to worry about types made easier. I don’t know if it was worth it for that one feature. With express middleware, you’re basically tacking on stuff to the request or response object as the flow moves through the request/response chain. This keeps the method signatures constant so (req, res, next), so you can easily chain async middleware functions. TS really borks that paradigm.

The moderators of this message board, otatop, L.Washington, WichitaDM, Yuv, JonnyA, RiskyFlush, and SvenO, are cowards who let abusers dox and harrass other long time posters.

1 Like

DeepMind AI is ready to pass the programming interview (sort of):

1 Like

Grunching, but what is the most effective and useful way to start coding nowadays? I’m a CPA doing some group accounting 10 hours per week but mostly I’m betting esports to pay the bills.

Here’s my 2c but I’m just a hobbyist so others might have better advice.

Pick a language and start playing around with it. Doesn’t really matter which one because it’s easy to transition to another if you need to. If you’ll be doing mathy code then Python / Julia / R might suit your needs. Think of a program you want to write, then open up the language’s documentation and start coding. There will be multiple ways to code it, but see what solution you can come up with using the available commands outlined in the manual. Some basic ingredients you’ll need are variables, types, arrays, if and else, for and while loops, and operators like && and || and ! and ==.

I actually would like to have an IDE that did this for Javascript (yes I know about coffeescript but no one uses that anymore). I think all languages should be indentation-based. It’s just so many less lines of code and easy to read. And you never get into tab vs. space wars.

Although here I would put a blank line between methods at least. Also fuck 4 space tabs. Why would I want to give up so much real estate? Another advantage of indentation-based is you can set tab stops to whatever you want.

2 Likes

As a service to the alumni of the university I work for, we let them create an @alumnI.XXX.edu email account. This used to be just a dumb forwarder, but then they converted it to gsuite. Which means our alumni can now create unlimited shared drives and hand them off to others.

This week we discovered 780 shared drives with terabytes of movies and porn, some of it very illegal. Someone compromised one alumni email and off they went - creating shared drives and then handing them off to others. I’m told gsuite offers no setting to limit this behavior.

I just found out about all of this. Now my boss wants to have a meeting to discuss how we can avoid this in the future. The first 20 minutes of the meeting will just be me going, “WTF? Why? What were they thinking? Why do alumni need shared drives?” and her getting increasingly annoyed at me. Should be fun.

https://m.imgur.com/2fIHmJp?r

  1. From the Admin console Home page, go to Apps > Google Workspace > Drive and Docs.
  2. Make sure that, for your organization, Drive is turned on.
  3. Click Sharing settings.
  4. To apply the setting to everyone, leave the top organizational unit selected. Otherwise, select a child >organizational unit.
  5. Click Shared drive creation and choose an option:
  • To allow users to create shared drives, uncheck the Prevent users in your organization from creating >new shared drives box.
  • To not allow users to create shared drives, check the Prevent users in your organization from creating >new shared drives box.
  1. Click Save. If you configured an organizational unit or group, you might be able to Inherit or Override a >parent organizational unit, or Unset a group.

It might take 24 hours for changes to take effect.

Thanks. I think the problem is that the setting for drives is either on or off, whereas we’d like a way to limit the user to their own drive and not allow them to create shared drives, or at least very much limit the number and capacity of shared drives they can create. Now that we’ve let users create their own drives and the cat is out of the bag, I don’t know if we can just turn the feature off. I’ll find out in the security meeting.

Apparently there is no way to limit the # of shared drives a user can create, and no way to limit the storage capacity of shared drives. Shared drives are limited to 400,000 items, but not size-constrained. One of the compromised drives had 1.2 petabytes of video files, mostly blu-ray rips of movies.

def setup(... #specify some parameters here
          ...):
    # do some manipulation of arguments here
    args = [('p', p_path, p_folders),
            ('x', x_path, x_folders),
            ('c', c_path, c_folders)]
    for drive, path, folders in args:
        # do some stuff with the unpacked args here

I’m writing a python function to automatically setup directory structures for projects. p_path, p_folders, etc., are arguments passed to the function (or in some cases are variables constructed from other arguments. Some of these would typically use default values and others would typically be specified by the user.

I have a questions about lines 4-6, which add some structure to the arguments so they can be used in a loop. Since I’m essentially typing the same line 3 times with one character changed, it makes me think maybe I should be doing this another way. But in this simple case, the alternatives don’t really seem better to me. E.g., you could rewrite those lines as a list comprehension, but I think that would get a little ugly because it would have to handle converting strings to code.

Just want to check if there’s some simple idiom I’m missing here or if maybe this is an indication that the code should be structured differently.

This seems fine to me. Sometimes you just have to do a bunch of things and there’s no especially elegant way to do it. You could inline args if it doesn’t mess with the formatting too much, but that’s just aesthetics. If you do leave the args variable in, though, you could give it a better name (it’s not really just a generic bag of args any more, you just painstakingly crafted all this internal structure!). Some people frown on single-use variables, so I always feel an obligation to give them very good names to justify their existence.

You could also extract the body of the loop as a function and just call it three times, rather than looping. (Basically make lines 4–6 three invocations of do_some_stuff.). That would be useful if you wanted to more easily test the stuff in the loop body.

Or just leave it as is, because it’s fine.

1 Like

The moderators of this message board, otatop, L.Washington, WichitaDM, Yuv, JonnyA, RiskyFlush, and SvenO, are cowards who let abusers dox and harrass other long time posters.

If I’m understanding correctly, you have variables for each drive letter. That is a mistake. You don’t want to have to edit code to add a new drive. Instead, have a dictionary with the key being the drive letter.

C can do what you say with macros and the stringify operator

#define MAKE_PATH(x) x##_path

I think python can do it, something like

globals()[‘p_path’]

but again I think it’s a sign of an earlier mistake.

The moderators of this message board, otatop, L.Washington, WichitaDM, Yuv, JonnyA, RiskyFlush, and SvenO, are cowards who let abusers dox and harrass other long time posters.

I think I ran into a use for a linked list a year ago or so. I can’t remember what it was and I don’t think I ever implemented it. But I remember because it was the first time I’ve thought, “Hey a linked list might be good for this”.

I’ve used FIFO stacks a few times. Those are fun.

And I’ve used a tree structure that was kind of like a linked list I guess, in that in creating the structure from a sorted list of items from the database, every member was either a child or a sibling of the member before it.