efficiency – How is it possible to work on large codebases?

Similar question:

I have always worked on small projects where editing a piece of code is easy: you modify the code, you recompile and in a matter of seconds you can play around with the compiled program.

Everyday one may end up doing the “edit compile try” loop hundreds if not thousands of times.

Some codebases however (e.g chromium) are huge, and require minutes to compile.

How do software engineers manage to efficently work on such large codebases? Do they recompile every time they make a small edit?

Sails.JS’s publish method doesn’t work in a controller, but works in the console

Currently, I’m exploring web development to see what all the hype is about. Except for following a small ‘create your first CRUD app in Node.JS’ and some formal training in JavaScript, I have no experience.

I’m new to JavaScript, NodeJS, Sails.JS, and WebSockets.

My current problem is this:

The app I’m trying to develop receives POST calls with a JSON object. This is the input part of the application. These POST calls originate from any random host.

The output is a webpage that updates itself by listening on a Sails.JS powered WebSocket system called sails.io.js.

Basically, each POST from any host should result in an event on the WebSocket.

Since I’m not building a formal REST API, I have to define some parts myself in Sails.JS. I do have blueprints enabled.

First, in the controller that handles the POST call, I can call the code below so existing WebSockets can receive an event of a new ServiceHeartBeatSession being created. All the server side code mentioned here is located in the controller or executed in the console.

sails.sockets.addRoomMembersToRooms(ServiceHeartBeatSession._classRoom()
, ServiceHeartBeatSession._room(session.id) );

Then, the invoke method is executed to send this event to all listening WebSockets.

ServiceHeartBeatSession.publish(( session.id ), { “verb”: “created” });

However, the .publish method does not result in a event to an existing WebSocket. Unless I execute it myself in the console. The WebSocket is registered like this:

io.socket.on(‘serviceheartbeatsession’, function(resData) {
alert(‘Something changed!!!!’);
});

I did some digging into the sourcecode and made some attempts at debugging this myself. Here’s what I’ve found so far:

Running the .publish call in the console produces the desired result.
It appears that the .addRoomMembersToRooms is a requirement for the .publish to work in the console. So I’m assuming that .addRoomMembersToRooms works as intended.
I tried the alternative below, but that doesn’t work in the controller. However, it does work in the Node console.
sails.sockets.broadcast(( ServiceHeartBeatSession._room(session.id) ), “serviceheartbeatsession”, ‘hi!’);

The following works as intended, but I prefer not to use that.
sails.io.sockets.emit(‘serviceheartbeatsession’, { verb: ‘created’ });

The above attempt lacked a room selection, so I dug a little deeper. The calls below where the result of a .publish method. However, only after repeating this in the console, it worked.

var emitter = sails.io.sockets;
emitter.in(‘sails_model_serviceheartbeatsession_5b6b26748377829d34983d67:serviceheartbeatsession’); // for example
emitter.emit(‘serviceheartbeatsession’, { verb: “created” });

Check more information in the article: https://adevait.com/nodejs/building-nodejs-apis-with-sailsjs
Anyone have any ideas?

 

mod security – Can’t get docker image owasp/modsecurity-crs:apache reverse proxy to work

I have an endpoint https://my-portal.nl and I wan’t to place a WAF with the OWASP Core rule set before it. So I found a Docker image(owasp/modsecurity-crs:apache) that can proxy all the requests to my endpoint (https://my-portal.nl). For some reason I can’t get it to work. When I browse for https://localhost I’m getting a

“Forbidden You don’t have permission to access this resource.”
response from the server.

This is the command I executed:

docker run -dti 
  --name apachecrs 
  --env PARANOIA=1 
  --env ANOMALYIN=5 
  --env ANOMALYOUT=5 
  --env ALLOWED_METHODS="GET POST HEAD" 
  --env MAX_FILE_SIZE=5242880 
  --env RESTRICTED_EXTENSIONS=".conf/" 
  --env PROXY=1 
  --env PORT=8443 
  --publish 443:443 
  --env BACKEND=https://my-portal.nl:8443 
  owasp/modsecurity-crs:apache

What am I doing wrong?

keyboard – Cursor changes from a filled box to an open box and keystrokes don’t work + strange screenlock behaviour, after change of SSD

After installing the SSD harddisk from another Macbook Air (both are from 2017, running Catalina, bought same day),
I encounter two strange problems:

  • after some inactivity, the cursor changes from a filled box to an open box and keystrokes are no longer taken (but mouse navigation still works); after closing the lid, opening it and entering the password given the screenlock, the cursor is a filled box and keystrokes work again;
  • sometimes, the screen suddenly locks, although the current settings are that it should lock no earlier than after 4h.

Can anyone help? What’s going on??? (I restarted a few times, no change).
Thanks a lot!
G

dnd 5e – Does the Brace maneuver work with Unarmed Strikes

You cannot wield an unarmed strike, so this does not work

The Brace Maneuver states:

When a creature you can see moves into the reach you have with the melee weapon you’re wielding, you can use your reaction to expend one superiority die and make one attack against the creature, using that weapon (…)

You cannot wield an unarmed strike. I come to this conclusion because the rules are written using natural language and if somebody told me they were wielding their head, foot, or hand, I would be very confused. However, there is a stronger argument to make:

Unarmed strikes are not weapons, so this does not work

Regardless of whether or not you can wield an unarmed strike, the feature requires a weapon at two different times and unarmed strikes are not weapons:

(…) Instead of using a weapon to make a melee weapon attack, you can use an unarmed strike: a punch, kick, head-butt, or similar forceful blow (none of which count as weapons). (…)

Because unarmed strikes are not themselves weapons, they cannot be used for the Brace Maneuver.

plugin development – Loop function does not work for each DB entry

/**
 * Fetch domains
 * 
 * @return array
 */
function external_nofollow_domain_all() {
    global $wpdb;
    return $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}external_nofollow_domain" );    
}
// Function to nofollow domain
function external_nofollow_domain_nofollow( $content ) {
    $domains = external_nofollow_domain_all();
    foreach ( $domains as $domain ) {
        $domDocument = new DOMDocument();
        $domContent = $domDocument->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES'));
        if (false === $domContent) {
            return $content;
        }
        $urls = $domDocument->getElementsByTagName('a');
        if (0 === count($urls)) {
            return $content;
        }
        $updatedContent = $domain->domain;
        foreach ( $urls as $url ) {
            $full_url = $url->getAttribute('href');
            $host_url = parse_url( $full_url );
            if ( $host_url('host') == $updatedContent ) {
                if (!empty ($domain->custom_class) ) {
                    $url->setAttribute('class', $domain->custom_class);
                } else {
                   // do something 
                }
                if (!empty ($domain->link_target) && $domain->link_target == "_self" ) {
                    $url->setAttribute('target', '_self');
                } elseif( $domain->link_target == "_blank" ) {
                    $url->setAttribute('target', '_blank');
                } else {
                    // do something
                }
                if (!empty ($domain->link_rel) && $domain->link_rel == "nofollow" ) {
                    $url->setAttribute('rel', 'nofollow noopener');
                } elseif( $domain->link_rel == "follow" ) {
                    $url->setAttribute('rel', 'follow');
                } else {
                    // do something
                }
            }
        }
    }
 return wp_kses_post($domDocument->saveHTML());
}

python – How to work with the data of a custom dataset in pytorch?

I’m new to pytorch, and I am loading my custom image dataset using torchvision.datasets.ImageFolder.

myDataset = ImageFolder(root=root, transform=ToTensor())

Now, I have 2 issues:

1- How can I get the size of the images (all the images of the dataset have same size) ? Currently, I’m using len like this, but I wanna know the easy way to get the dimension of the dataset:

nt = len(myDataset) #number of images
nClasses = len(myDataset(0)) #number of classes
nc = len(myDataset(0)(0)) #depth (RGB)
nf = len(myDataset(0)(0)(0)) #length
ns = len(myDataset(0)(0)(0)(0)) #width

2- I have to unsqueeze my data to be able to feed them to my NN model. I know about tensor.unsqueeze, but how should I apply it to my dataset?

MANUAL WORK 100 BLOG COMMENT BACKLINKS for $22

Select a reason you’re reporting this service

.

Navigating to SharePoint using teamslogon.aspx doesn’t work Teams mobile

I want to navigate SharePoint in Teams tab app by clicking button as below, but it doesn’t work properly only in MS Teams Mobile app(works with desktop), it shows the loading screen.

var url= https://${DOMAIN_URL}/_layouts/15/teamslogon.aspx?spfx=true&dest=/${SITE_URL};
window.location.replace( url );

is there any reason for that ?

enter image description here

manifest similar to this

 "staticTabs": (
         {
             "entityId": "16f1325347cb",
             "name": "Portals7",
             "contentUrl": "https://my-site-url.io/Tab?loginHint={loginHint}&userObjectId={userObjectId}&userPrincipalName={userPrincipalName}&tenantId={tid}&locale={locale}&theme={theme}&userPrincipalName={userPrincipalName}",
    
             "websiteUrl": "https://my-site-url.io/Tab",
             
             "scopes": ("personal"),
             "supportedPlatform" : ("desktop")
         }
     ),
   "permissions": (
     "identity",
     "messageTeamMembers"
   ),
   "validDomains": (
   "my-site-url.io",
      
     "*.login.microsoftonline.com",
     "*.sharepoint.com",
     "*.sharepoint-df.com",
     "spoppe-a.akamaihd.net",
     "spoprod-a.akamaihd.net",
     "resourceseng.blob.core.windows.net",
     "msft.spoppe.com"
   ),
   "webApplicationInfo": {
     "id": "00000003-0000-0ff1-ce00-000000000000",
     "resource": "https://{teamSiteDomain}"
   }
 } 

dnd 5e – Does the whirlwind spell work during a battle at sea?

While I think that the surface of the sea ought to work as ‘ground’ in naval battles, where using whirlwind could clear the decks of the opposing ship’s crew and render it disabled, the spell says this:

A whirlwind howls down to a point that you can see on the ground
within range. The whirlwind is a 10-foot-radius, 30-foot-high cylinder
centered on that point. Until the spell ends, you can use your action
to move the whirlwind up to 30 feet in any direction along the
ground.
The whirlwind sucks up any Medium or smaller objects that
aren’t secured to anything and that aren’t worn or carried by anyone.
{snip damage and restrained bit}

It would also be helpful clarifying if the deck of the opposing ship constitutes “the ground” for this spell. I think that it should, but does it?