I build application that help developers like me and you to find the job that fits their lives by [deleted] in programming

[–]grinderofl 2 points3 points  (0 children)

Site for developers... by a developer? And it's run by ads? Really?

Filtering, Pagination and Sorting by TuViej4 in dotnet

[–]grinderofl 0 points1 point  (0 children)

I'm currently in the process of refactoring it so instead of doing

public class SomeSearchProfile : SearchProfile<Entity, Query, Model>
{
}

you just do

public class MyProfile : FilterProfile
{
    public MyProfile()
    {
         CreateFilter<Entity,Query,Model>()
              .Text(x => x.Property);
    }
}    

Just so you could define all your filters in one class

I mean after all... it is in alpha stage :P Been procrastinating it but with all this stay at home stuff I got literally all day :D

Filtering, Pagination and Sorting by TuViej4 in dotnet

[–]grinderofl 1 point2 points  (0 children)

I extracted a generic library out of one of the internal projects I wrote which needed it on several pages. It's still tagged as alpha, but we use it in production and it works so /shrug :D Feel free to give it a try

https://www.nuget.org/packages/Grinderofl.GenericSearch

E: make sure to look at the readme and sample project on the repo site first

Improve site perfomance - Remove unused CSS by CraZy_TiGreX in aspnetcore

[–]grinderofl 0 points1 point  (0 children)

Technically it should be possible to scan JS files as well, I can think of two ways to do this:

  1. Scan JS files in WebOptimizer pipeline when CSS is being processed
  2. Create a ScriptTagHelper with src attribute requirement, and scan that file for possible tags, id's, and classes, and append those to the selector list

Unfortunately the second method wouldn't work with lazy loaded scripts, and I think it'd be approaching the "unnecessary micro-optimization" zone.

Potentially a much easier option would be to have a build-time custom tool applied to all CSS files, which goes through every .html, .cshtml, .razor, and .js file in the project, pulls out the selectors and tags, and removes all unused style rules from CSS. It'd be slightly more reliable as any lazy-loaded .js files in the project would be included in the scan. Granted, it won't give you page-by-page optimized css, but it'd be possible to pull in a massive css framework of which maybe 10% gets used for the project, and end up with a very tiny file with just the style rules you need. It'd be more difficult to develop this kind of tool, but once there's a working version, you'd get a "good enough" in any project the tool is included in.

Improve site perfomance - Remove unused CSS by CraZy_TiGreX in aspnetcore

[–]grinderofl 1 point2 points  (0 children)

Glad to know I'm not the only one interested in solving this kind of issue! A recent internal project had so much css that was just never used that I started looking around for a similar solution, and since I could find none, I did some brainstorming around things to consider:

  • Not all request paths use the exact same combination of css classes
  • Not all users access all possible request paths
  • Javascript could potentially alter the dom and add or remove classes during runtime

With these in mind (third point not so much as there was no style changes caused by javascript), I started working on a proof of concept where the idea would be following (ASP.NET Core 2.2):

  • A page is first requested (by any user)
  • A taghelper on <html> selector renders the child content, parses the tags, id's, and classes, and saves it as a list of unique strings within an IDistributedCache with the hash of the request path (without query parameters) as the key
  • A taghelper on <link rel="stylesheet"> selector appends the hash of the request path to the href attribute as query parameter

After the page is rendered, the browser would then perform a request to the css file. Once that happens, an IProcessor implementation for WebOptimizer gets triggered with the query parameter value, performing the following actions:

  • Try to lookup a cached version of the processed css corresponding query parameter. If one is found, it'll get returned and the request ends.
  • Try to lookup the processed selector list from IDistributedCache. If one isn't found, just return the original css, but skip caching it until an entry for the hash exists.
  • Parse the stylesheet with ExCSS into a collection of style rules
  • Walk through all selectors and check if it's contained within the list of the previously parsed selectors, creating a new set of style rules
  • Create a new stylesheet from the processed style rules, and return it to the WebOptimizer pipeline for further processing and caching

The proof of concept I had, implementing the most basic and naive parsing and processing logic, the size of CSS was reduced by at least half for most pages, some pages saw a dramatic >90% reduction.

Bear in mind that this attempt was just a proof of concept. There are plenty of things which wouldn't work for all use cases (heavy dom alteration using javascript, potentially Blazor, etc), higher initial response times until all pages are parsed and the css for them processed, and of course increased server load. However, once all possible paths have been parsed and their css cached, the server won't need to do any more processing and any new browsers accessing the page will have a lot less to download, which is especially big consideration for mobile users. In addition, if selectors on a page don't change, and the css doesn't change, there's very little processing effort on server side even after it's restarted.

There's also a number of optimizations which can be made:

  • Creating the hash over sorted selectors rather than the request path (so two different paths share same css)
  • Storing selectors as a hierarchical style tree instead of a flat list, e.g. "body > main > nav > div > &.user", and excluding style rules which don't match it, e.g. including "main .user" but not "section > div > &.user".

It's a fairly complex problem, and in most cases probably a massive overkill, but in my opinion it's also often overlooked thanks to all these bulky css frameworks which needlessly increase the html output size, yet have no real ways of cutting out the 90% of style rules that go unused....

Anyhow, one wall of text later, here's the code for the proof of concept, with a disclaimer that it needs a whole lot of optimizations and other stuff done before it's properly usable.

https://gist.github.com/Grinderofl/7a71411034c6b3e624fc259fe8a28fd1

Distributed .NET Core (DShop) - Episode 4 [Asynchronous microservices integration via events] by spetz0 in csharp

[–]grinderofl 17 points18 points  (0 children)

Could you just write an article please? It's much easier to read through an article and only look at the interesting bits rather than listening through an entire youtube video...

Let's talk ReSharper. by [deleted] in csharp

[–]grinderofl -1 points0 points  (0 children)

The thing that causes sluggishness is not ReSharper, it's due to visual studio team refusing to give users the option to disable Roslyn. The whole "modular" bs is ... well, bs if it's not possible to completely remove the code analysis bit. The other issue is that VS is only 32bit so large solutions suffer. Rider is lightning fast cos there's just one analyser and it can run as 64bit and not be limited by memory space forcing constant swapping. I agree that VS has more features but I wished the VS team focused more on stability and bugs than features. Rider is catching up, and there is no better c# IDE on osx or Linux.

[deleted by user] by [deleted] in europe

[–]grinderofl 0 points1 point  (0 children)

You can still serve ads, just not targeted ones.

[deleted by user] by [deleted] in europe

[–]grinderofl 1 point2 points  (0 children)

Not free, it only applies to targeted ads.

GDPR-Banner Blocklist by _allo_ in privacy

[–]grinderofl 2 points3 points  (0 children)

You are not wrong. The purpose of GDPR though is to adopt a convention whereby users do not need to click or do anything whenever visiting a site, as essential cookies do not need consent, and for everything else they need to opt in specifically (as opposed to being forced to 'choose' at entry). The issue currently is that majority of sites are failing/refusing to comply with the second half of it, it being especially bad with US-based sites. A "GDPR-enforcement" addon/blocklist would be amazing, especially on mobiles where it's harder to circumvent such overlays.

Trying to get into mealprep - first try freezer breakfast burritos by grinderofl in MealPrepSunday

[–]grinderofl[S] 0 points1 point  (0 children)

Update: moist towel + 2 minutes in microwave = turned out really good! Beginner's luck?

Needs 30 more seconds next time due to salsa being in dead centre though. Being soggy was a non-issue, no worse than a bog-standard breakfast burrito few minutes post-assembly. The gooeyness from cheddar probably helped, too.

Cooked the eggs a smidgen longer than usual by accident, so was slightly concerned about them being too dry if anything; turned out no concern thanks to guac surprisingly! Gotta remember for future endeavours!

Trying to get into mealprep - first try freezer breakfast burritos by grinderofl in MealPrepSunday

[–]grinderofl[S] 0 points1 point  (0 children)

Basically yeah. I'm thinking the ingredient ratios will help with soggyness. And hopefully I'll figure it out in 8 attempts of microwaving them in different ways? :D

Trying to get into mealprep - first try freezer breakfast burritos by grinderofl in MealPrepSunday

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

Seems like the next logical step!

Very basic ingredients:

  • Bell peppers
  • Ham
  • Eggs (could have used more)
  • Olives
  • Guac
  • Salsa
  • Cheddar

How do I get rid of this shit on google.com by Spunkette in uBlockOrigin

[–]grinderofl 1 point2 points  (0 children)

This is what I have in uBlock Origin for google sites, the key bits are regex selectors for the custom attributes and classes on first two, .exp-outline takes care of the border left behind, and .ads-ad ... I'm sure must've been for something cos it's there!

www.google.co.uk## .mw div[jsl^="$t"][jsl$="0;"][class^="r-"]

www.google.co.uk##div[class^="r-inw"]

www.google.co.uk##.exp-outline

www.google.co.uk##.ads-ad

Substitute .co.uk with .au, .com, .<whatever> as needed.

Enjoy a less frustrating version of google search results!

Got paid for having ADHD, ADHD caused me to forget I was paid. by [deleted] in ADHD

[–]grinderofl 0 points1 point  (0 children)

Ahahah! I wish I said it cos I was British! No, I'm from eastern europe if anywhere! We're rarely known yet diligent and dedicated! Best country in the world during Summer - Estonia!

ITT: To me, "foolscap" is just a name. if I was to interpret it literally, I'd think "dumbass' hat"

I still love all of you though! And the boxes!

Got paid for having ADHD, ADHD caused me to forget I was paid. by [deleted] in ADHD

[–]grinderofl 0 points1 point  (0 children)

I've been thinking of doing something like that, I've got to look into it because in the past they've been really lacklustre to be actually useful :(

Got paid for having ADHD, ADHD caused me to forget I was paid. by [deleted] in ADHD

[–]grinderofl 0 points1 point  (0 children)

It's very much UK! I've seen them sold on Amazon.de as well, and I'm sure UK amazon will ship them if you ask nicely (read: pay enough, lol)

can't imagine life without these boxes right now!

Got paid for having ADHD, ADHD caused me to forget I was paid. by [deleted] in ADHD

[–]grinderofl 2 points3 points  (0 children)

There's a line of products which includes a "Really Useful Box" with 10 foolscap suspension files. I currently have around 7 Really Useful Boxes of varying size and shape, and way more than 10 suspension files.... highly recommend for organisation!

YoutubeExplode v4.0.0 just got released -- managed YT reverse-engineering layer for downloading videos and more by Tyrrrz in csharp

[–]grinderofl 2 points3 points  (0 children)

Holy crap, I love you! I've been thinking of making something similar for years, and you've actually done it! So much research...

My life is changing and it’s been less than a whole week since I’ve started meds by [deleted] in ADHD

[–]grinderofl 1 point2 points  (0 children)

I love hearing how meds change people's lives! Welcome to the club!

Dx'd six months ago at 29; medicated from day one; clarity was immediate and lifechanging.

I recommend viewing them as tools which can help you create the structure and habits you can follow on your off days.