How many ways to express N as sum of 2, 3 and 5?

I’ve learnt about problems about express N as sum of 2, 3, 5. For examples, if N = 7:

  • N = 5 + 2

  • N = 2 + 5

  • N = 2 + 2 + 3

  • N = 2 + 3 + 2

  • N = 3 + 2 + 2

But most of I found on the Internet that the different position is different way to express N (as this link for expressing N as sum of 1, 3, 4). Following that link, I try following DP formula:

    f[0] = f[1] = 0 ;     f[2] = f[3] = f[4] = 1;     for(int i = 5; i < 100; i++) {         f[i] = f[i-2] + f[i-3] + f[i-5];     } 

But it isn’t correct, as N = 7, F[N] = 4. So what is the correct DP method for this problem?

Hard version: I also concern about don’t care order of way to express N, such as N = 2 + 2 + 3 and N = 2 + 3 + 2 and N = 3 + 2 + 2 will be only count as 1 time.

Note that I’m trying to solve above problem in complexity O(N).

How to fix an overwhelming UI for reporting with too many options?

I’m having a difficult time organizing the excessive number of listboxes for a report I’ve been asked to write.

They want tons of filter options with multiple select lists. Is there a better way to organize these lists or an alternative to listboxes that may look cleaner? I can hide the listboxes when the checkboxes are checked but that still doesn’t look great to me.

This makes my eyes hurt:

page layout with listboxes


I decided to use a Progressive Disclosure design pattern to clean this up a bit. I’ll continue to improve it as I learn more. Thanks Son Do Lenh for the answer!

new page layout

Event viewer security logs show many anonymous logins how do I exchange the public ip for the private ip?

I’m noticing a lot of anonymous logins. I have read through this forum that they could be harmless but I’d like to look into it deeper and find the source ip (private ip) to make sure its local. The post I read the guy said was from his anonymous login user and that was in Taiwan but he was in the US. So it was concerning because none of his network was in Taiwan…


How many different ways are there to create a “page” in Drupal 8?

By page I mean what’s served by a given route/url. Trying to understand all the options so I know what I can combine (e.g. create a View, and use a render alter hook to add a form at the bottom).

Here’s my incomplete list:

  • Controller
  • View
  • Form
  • Backend creation of pages, articles, custom content types.
  • Contact Forms
  • ?

How to fix ‘Too many levels of symbolic links’ error in virtuanenv? [on hold]

I am getting error(Too many symbolic link levels) while setting up virtual envirionment in Django web application framework.

I tried to look the following question and answer on stack overflow:

mkvirtualenv: Too many levels of symbolic links

virtualenv: Too many levels of symbolic links

Kuldeeps-MacBook-Pro:trydjango kuldeep$   pip freeze   branca==0.3.0   certifi==2018.8.24   chardet==3.0.4   folium==0.6.0+11.g71ab988   idna==2.7   Jinja2==2.10   MarkupSafe==1.0   numpy==1.15.1   requests==2.19.1   six==1.11.0   urllib3==1.23   virtualenv==16.1.0 Kuldeeps-MacBook-Pro:trydjango kuldeep$   source bin/activate Kuldeeps-MacBook-Pro:trydjango kuldeep$   ls bin     db.sqlite3  include     lib   src     trydjango Kuldeeps-MacBook-Pro:trydjango kuldeep$   pip freeze -bash: /Users/kuldeep/Dev/trydjango/bin/pip: /Users/kuldeep/Dev/trydjango/bin/python3: bad interpreter: Too many levels of symbolic links 

MySQL PDO Too many connections

I have an application that is constantly inserting to a stats table. The average number of open connections is usually about 20 to 22.

There is also a processing script in PHP run by a cron that runs every 30 minutes. Around 2am UTC it takes about 10 minutes to process which is the longest amount of time during a day.

Around this time, I’m getting about 8000 PDOException: SQLSTATE[08004] [1040] Too many connections errors.

The max_connections is set to 500.

I’ve observed that by doing SHOW PROCESSLIST; I don’t usually see any queries in the Info column. While the cron is running, I do see the query for the cron in the Info column and then the SQL inserts quickly pile up below it.

I don’t really know a great deal about configuring MySQL but it seems like the inserts to the stats table are getting queued and surpassing the max connection limit while the Cron script is running.

What can be causing this and which configuration settings should I look at changing?

CSOM site provisioning error: The request uses too many resources

I continue to get an error (sometimes) when provisioning a web using CSOM. According to this MSDN article, this error is returned when the CSOM request exceeds 2MB. I watched the call in Fiddler and the request is not greater that 2MB. What could the problem be? Below is the code and request/response from fiddler:

   using (ClientContext cc = new ClientContext(url))     {         cc.Credentials = new SharePointOnlineCredentials(username, password);         WebCreationInformation information = new WebCreationInformation();        information.WebTemplate = "CMSPUBLISHING#0";        information.Description = "My New Site";        information.Title = "My New Site";        information.Url = "newsite";        // Currently all English, could be extended to be configurable based on language pack usage         information.Language = 1033;         information.UseSamePermissionsAsParentSite = false;          cc.Web.Webs.Add(information);         cc.ExecuteQueryRetry(); } 

Fiddler Request:

<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="" LibraryVersion="" ApplicationName=".NET Library" xmlns=""><Actions><ObjectPath Id="1158" ObjectPathId="1157" /><ObjectIdentityQuery Id="1159" ObjectPathId="1157" /></Actions><ObjectPaths><Method Id="1157" ParentId="923" Name="Add"><Parameters><Parameter TypeId="{8f9e9fbe-189e-492f-884f-98f9ef9cc4d6}"><Property Name="Description" Type="String"></Property><Property Name="Language" Type="Int32">1033</Property><Property Name="Title" Type="String">Manuals</Property><Property Name="Url" Type="String">manuals</Property><Property Name="UseSamePermissionsAsParentSite" Type="Boolean">false</Property><Property Name="WebTemplate" Type="String">CMSPUBLISHING#0</Property></Parameter></Parameters></Method><Property Id="923" ParentId="384" Name="Webs" /><Identity Id="384" Name="7e19049d-e009-2000-008d-b659834a548f|740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:a43f2ef7-f1aa-423a-ad26-59b66edef6bb:web:a30643dc-7034-47ae-b87e-119ef8a2975d" /></ObjectPaths></Request> 

Fiddler Response:

HTTP/1.1 200 OK Cache-Control: private Content-Type: application/json; charset=utf-8 Vary: Accept-Encoding Server: Microsoft-IIS/8.5 X-SharePointHealthScore: 0 X-SP-SERVERSTATE: ReadOnly=0 SPClientServiceRequestDuration: 7513 X-AspNet-Version: 4.0.30319 SPRequestGuid: 7e19049d-601e-2000-008d-b31e125c7e26 request-id: 7e19049d-601e-2000-008d-b31e125c7e26 X-RequestDigest: 0x1B109C2C5737406AB9E9A2983D743443F86CEF7D92CD6041BB1510FCDD2A4866A55C5BF0D32E4E55C4448C12C9727F191740AAF929E6353320C1CAE0FBBC1D16,07 May 2015 17:27:33 -0000 X-FRAME-OPTIONS: SAMEORIGIN X-Powered-By: ASP.NET MicrosoftSharePointTeamServices: X-Content-Type-Options: nosniff X-MS-InvokeApp: 1; RequireReadOnly P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI" Date: Thu, 07 May 2015 17:27:40 GMT Content-Length: 574  [ { "SchemaVersion":"","LibraryVersion":"16.0.4021.1200","ErrorInfo":{ "ErrorMessage":"Provisioning did not succeed. Details: Failed to initialize some site properties for Web at Url: 'https:\u002f\\u002fsites\u002fPaulDev\u002fcompany\u002fACS\u002fmanuals' OriginalException: The request uses too many resources.","ErrorValue":null,"TraceCorrelationId":"7e19049d-601e-2000-008d-b31e125c7e26","ErrorCode":-2146232832,"ErrorTypeName":"Microsoft.SharePoint.SPException" },"TraceCorrelationId":"7e19049d-601e-2000-008d-b31e125c7e26" } ]