C programming Lab Questions – Stack Overflow


Your privacy


By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.




api – Google credentials and redirect URI for Google OAuth2 in a WordPress plugin, questions

I’m developing a plugin that inserts contacts into a custom table of the WordPress database (name, phone number, email). It is possible to enter data in this table either manually, through a form, or by importing it from WordPress users. I have also developed a feature to import contacts from Google Contacts (Google People). Everything works but I ask you: when I will provide the plugin to my customers how can I do to avoid also providing the client_secret.json file with my credentials for accessing the Google API via OAuth2 together with the plugin?
Furthermore, in order to function correctly, I must also authorize the URI redirect in the Google console but I cannot know in advance the URL of the various sites where the plugin will be installed, is it possible to automate (perhaps always through the Google API) this insertion?

New to socket programming in C#.. Have very basic questions

New to socket programming in C#.. Have very basic questions – Software Engineering Stack Exchange

Questions about file objects : removing, closing etc

  1. Does os.remove(<file_object>) automatically close <file_object> ? Should I do a <file_object>.close() beforehand ?
  2. What happens to all attributes of <file_object after <file_object>.close() or equivalent closure, for example, is <file_object>.close(); print(<file_object>.name) reliably valid, and how/why.

raid – Windows 10 drives pool questions (replace, upgrade)

i have some questions about Windows 10 pool.

Let’s suppose i have 4 disks ot 4TB and i choose the parity option. This means Window will simulate a RAID 6? Because in my test i see 8TB as drive space.
Considering is a Windows 10 pro, can i shutdown the PC without any problem or it must stay running for let pool work?

If one drive fail, i should wait Windows remove the drive from pool, but i need to remove the drive from the case while the PC is running or i can shutdown, replace the drive, turn on the PC?

What happening if i add a new drive with a different size? For example 6TB instead of 4TB?

Thank you for your answers!

interview questions – Square Spiral Matrix in Javascript

I’ve been grinding some Leetcode for an interview coming up and just completed Square Spiral in Javascript.

Looking for feedback on performance. This ranked faster than 58% of submissions, would there be anyway to increase the speed using a similar implementation to what I have here?

enter image description here

let matrix = (
  (1, 2, 3, 4,  5),
  (6, 7, 8, 9, 10),
  (11,12,13,14,15),
  (16,17,18,19,20),
  (21,22,23,24,25)
)

var spiralOrder = (matrix) => {
  //make copy
  var dup=JSON.parse(JSON.stringify(matrix));
  //setup variables
  let maxX, maxY, baseX, baseY, x, y, vecX, vecY, nums, totalSquares;

  //Max indexes for array and sub arrays
  maxY=matrix(0).length-1;
  maxX=matrix.length-1;

  //baseX tells x when it has reached the first sub array.
  baseX=0;
  
  //baseY tells y when it has reached the first index of a sub array.
  baseY=0;
    
  //our indexes
  x=0;
  y=0;
    
  //our movement vectors
  vecX=0;
  vecY=0;
    
  //the count for keeping track of positions iterated
  count=0;
    
  //the total amount of squares to be iterated
  totalSquares=matrix.length*matrix(0).length;
    
  //return value array
  nums=();

  //I don't get how subArrays with only a single element could
  //still be considered spiralable, but this if-statement handles
  //those edge cases. Thanks Leetcode.
  if (matrix(0).length===1) {
    for (var i=0;i<matrix.length;i++) {
      nums.push(matrix(i)(0))
    }
    return nums
  }
    
  //While our iterated count is not equal to the total amount of
  //squares to be iterated. When this is true we know we
  //have completed the spiral.
  while(count!==totalSquares) {
      
    nums.push(dup(x)(y));
    count++;

    //Our loop iterates around in a spiral. On every turn
    //the loop increases the opposite side baseX, baseY,
    //maxX or maxY to increase the tightness of the spiral
    //as it loops.
      
    //This handles starting the very first iteration, moving right.
    if (x===0&&y===0) {
      vecX=0;
      vecY=1;
    //We've reached the top rightmost square, move down.
    } else if (x===baseX&&y===maxY) {
      vecX=1;
      vecY=0;

      //This is a little confusing. We can't increment baseY
      //until after the first iteration through the
      //first sub array is complete. This if statement
      //confirms that we're clear to increment baseY.
      if (baseX>0) {
        baseY+=1;
      }
    //We've reached bottom rightmost square, move left, increment baseX. 
    } else if (x===maxX&&y===maxY) {
      vecX=0;
      vecY=-1;
      baseX+=1;
    //We've reached bottom leftmost square, move up, decrement maxY.
    } else if (x===maxX&&y===baseY) {
      vecX=-1;
      vecY=0
      maxY-=1;
    //We've reached top leftmost square, move right, decrement maxX.
    } else if (x===baseX&&y===baseY) {
      vecX=0;
      vecY=1;
      maxX-=1;
    }

    //Increment x or y by the vector.
    x+=vecX;
    y+=vecY;
  }

  return nums
}

```

Google Answers Common Questions About Appearing in Google News

Google tries to clear up some challenging questions about inclusion in Google News.

Essential Return-To-Work Survey Questions That Business Should Consider

Are you panicking about covid-19? Look below to find some of the top return to work survey questions that your business must consider.

In the past few months, government authorities are starting to take measures for reopening businesses. However, in the post-covid-19 scenario, there are a few return-to-work survey questions that every business should consider when getting back to work after quarantine. This is because the ongoing pandemic is highly fluid and depends on the sector and jurisdiction-specific consideration. Therefore, employers must take care in bringing their employees back to their workspace.

Which social distancing norms should a business consider?

Employers need to comply with the directives of the local, federals, and state on social distancing when reopening their workplace. They have to consider alternative workdays and limited work hours. Moreover, they must lower the number of employees who are present on-site and avoid overcrowding. The employees require a physical barrier to limit sharing supplies or equipment.

Lastly, there are a few other covid-19 survey questions in terms of social distancing. These include considering the layout of your workspace along with modifying or closing common areas.


When must employers reopen their physical business locations?

Reopening businesses will depend on the employer’s industry and location. States must reopen their companies in phases. Besides, following the CDC guidelines is vital for each business. You have to restrict operations to some critical workers. Moreover, limiting non-essential employees from coming to the workplace is significant. Employers must further take care to minimize contact between employees who return to their workplace.

In addition, some companies must rethink if their community no longer requires much mitigation. Return to work covid-19 survey must take into account sick employees and establish routine and health checks.


How to maintain working in a remote manner?

Employers must consider hybrid working remotely for some months and not rely solely on the availability of normal workplaces. Rolling exits and lockdowns are going to continue in some regions where the covid-19 threat remains higher. It may be disruptive to swing back and forth between remote and central working states. However, a minimal workforce will be able to practice it productively and successfully.

For economic purposes, therefore, organizations need to keep employees working from home. However, some employees have to return to work if someone contracts the virus. This covid-19 questionnaire for employees will reinforce effective communication between employees.


Who can return to the workspace?

Employees must not ask all employees to join together at the same time. They need to ask workers to return gradually and with a low density. This will allow them to work freely without much stress.

Workers who are obese, have chronic heart or lung disease, and those over sixty must work remotely. Employees who do not have access to child care can continue to work from home. Employers also need to conduct return to work survey questions to know whether their employees feel comfortable returning to work.

 

currencies – Is there a Cryptocurrency Stack site anywhere for non-Bitcoin questions?


Your privacy


By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.




Questions about Lightning Network: Connectivity, Funding, Dealing w Bad Counterparties

TLDR

Long time buyer, holder, and user of Bitcoin (since 2015). Absolutely zero experience with Lightning Network. I’ve read some entry-level tutorials but still have basic conceptual questions regarding funding, capacity, revocations, etc.

Hypothetical Situation

Let’s say I run a gambling site. All business is conducted in BTC. More and more customers are asking that Lightning Network be made available to facilitate quick and cheap deposit and withdrawal of funds.

Where do I connect for maximum reach?

The tutorials always seem show to show two parties, Bob and Alice. They open a “channel” using a funding transaction. The example then typically adds in a third party (e.g. Festus) and says something along the lines of “and look, Bob can pay Festus through Alice.”

The implication seems to be that the network size could become enormous, to the point where anyone can pay anyone because hey, every Bitcoin user is inevitably connected by only a few degrees of separation on the network.

But this doesn’t really answer the question of to whom I, as a brand new user, should connect? I could connect to you, I guess. But maybe you’re a new user too and have zero other connections. Do I connect to some sort of hub? Guess that would work but doesn’t that make things overly centralized?

As a site owner (see hypothetical above), is it best for me to act as a hub and open a channel with each of my users, which means I’d have thousands of channels open? Or is it better to make a single connection to one really popular, well-connected dude? Seems like the latter, but which dude? How do I find him?

Do I always have to be online looking for cheats?

Ok, so I get that my LN peer can try to cheat me by broadcasting a settlement transaction of a prior balance state that’s more advantageous to him. And I also know that his cheat TX settlement won’t clear for twenty-four hours, giving me time to broadcast a “revocation” TX that settles everything in my favor instead. This is what dissuades my peer from cheating.

But this also implies that my Lightning node needs to be up 24/7, or at least never offline for more than 24 hours and, furthermore, I have to be ever vigilant to make sure no one is cheating, and execute revocations if they are. Are these assumptions correct? Does the Lightning software automate the cheat-detection process for me?

How do I add funds to an existing channel?

It’s still not clear how to add funds to a preexisting channel. I’ve seen some material online indicating that a third party service needs to be paid for this? I can’t imagine that’s correct is it? That doesn’t seem compatible with the whole ethos of LN.

Using my hypothetical example. Let’s say a client opens a channel with me and sends me 1 BTC. He bets on an upcoming UFC fight (Ronda Rousey vs. Oprah Winfrey). A successful bet on Winfrey pays 15x. That means in the unlikely even that he wins, I need to have at least 15 BTC available on that channel to pay him out.

How do I add funds to the channel if he wins? Or does that 15 BTC have to be placed in the channel via the initial funding transaction?

Now, if I’m servicing all users over a single channel, that’s fine. But if each user has his own channel, I’d have to fund each one with an enormous amount of BTC — despite the fact that 99.99% of my users will never even bet on that particular event at all. That would be an inefficient use of funds. I assume there’s a way to add funds to a channel after initial funding, but how?

Wallets

I’m running on Win 2019 Server and need to be able to create channels, send funds, be notified of incoming funds, etc. using an API. Which wallets support this?

With Bitcoin’s first layer, I have the option of either running a full blown node or leveraging a centralized service like Electrum? Does LN have an analogous situation with two different styles of wallet?

DreamProxies - Cheapest USA Elite Private Proxies 100 Cheap USA Private Proxies Buy 200 Cheap USA Private Proxies 400 Best Private Proxies Cheap 1000 USA Private Proxies 2000 USA Private Proxies 5000 Cheap USA Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive.com Proxies-free.com New Proxy Lists Every Day Proxies123.com Best Quality USA Private Proxies