Don't wanna be here? Send us removal request.
Link
This started to be a little be more of a challenge one night more then I thought. The issue was that I need to have position in my list of products. Which were in a ItemList when I used the itemtype in the same div I didn't have the option to add position; a requirement for ItemListElement. This all came from about because I was simplifying my list of products by just displaying them on a single page with prices. I wanted to put them list however looking back after a long night I could have easily just listed them as separate Product types. So to summarize the issue I wanted to meet all the requirements from Google's Structured Data Tool and didn't think listing them as multiple Products was right and instead did them as ItemList. Not to be confused with ListItem which is a type that can be at the root but also under ItemListElement. Its all very confusing at first glance. The next question I asked... Is it okay to have more than one Product
Example: (this doesn't have position or url property)
<div class='results' itemscope itemtype="http://schema.org/ItemList"> <meta itemprop="itemListOrder" content="Descending" /> <strong itemprop="name">2 Items</strong> <div class='item' itemprop="itemListElement" itemscope itemtype="http://schema.org/Product"> <h3 itemprop="name">Item 1 Title</h3> <img itemprop='image' src="bmw1.jpg" alt='Item 1 Description' /> <span class='description' itemprop="description"> Item 1 description of the item. Includes some basic comparison details. </span> <div class='pricing' itemprop="offers" itemscope itemtype="http://schema.org/Offer"> <span itemprop="price">$45,500.00</span> <link itemprop="availability" href="http://schema.org/InStock"/> </div> </div> <div class='item' itemprop="itemListElement" itemscope itemtype="http://schema.org/Product"> <h3 itemprop="name">Item 2 Title</h3> <img itemprop='image' src="bmw2.jpg" alt='Item 2 Description' /> <span class='description' itemprop="description"> Item 2 description of the item. Includes some basic comparison details. </span> <div class='pricing' itemprop="offers" itemscope itemtype="http://schema.org/Offer"> <span itemprop="price">$44,550.00</span> <link itemprop="availability" href="http://schema.org/InStock"/> </div> </div> </div>
Now in my solution I break it up by using both ItemList and ListItem inside the ItemListElement referenced earlier! However I will note that you can write all this in separate Product types but why would you mess with that awesome look within the Data Structure Tool at the end!? Just joking... My Solution
<ol itemscope itemtype="http://schema.org/ItemList"> <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"> <meta itemprop="position" content="1" /> <div class="media" itemprop="item" itemscope="" itemtype="http://schema.org/Product"> <div class="media-left"> <a href="#"> <img itemprop="image" class="media-object" width="125" src="/images/amsoil/API.jpg" alt="P.i. Performance Improver Gasoline Additive"> </a> </div> <meta itemprop="sku" content="APICN-EA"> <div class="media-body"> <a itemprop="url" href="/Products/Amsoil/APICN-EA"> <h4 itemprop="name" class="media-heading">P.i. Performance Improver Gasoline Additive</h4> </a> <br> <div itemprop="offers" itemtype="http://schema.org/Offer" itemscope=""> <h1 style="line-height: 0;"> <span itemprop="price">$13.85</span> </h1> <sub>Price (USD)</sub> <meta itemprop="priceCurrency" content="USD"> <meta itemprop="availability" content="https://schema.org/InStock"> </div> <br> <ul class="nav nav-tabs"> <li class="nav-item active"> <a class="nav-link active" data-toggle="tab" href="#home">Description</a> </li> </ul> <!-- Tab panes --> <div class="tab-content"> <div class="tab-pane active container" id="home"> <p itemprop="description"> P.i. improves fuel mileage an average of 2.3% and up to 5.7%. Reduces emissions such as hydrocarbons (HC) up to 15%, carbon monoxide (CO) up to 26% and nitrous oxides (NOx) up to 17%. Restores power and performance. Reduces the need for costly higher octane fuel. (API) </p> </div> </div> </div> </div> </li> </ol>
Errors to look for.. "Error in Google SDTT: “All values provided for url must point to the same page.” my issue came up because I had a space before the value, which cause the last record in the list to not count toward the requirement. Notes for Later I did notice that SomeProducts was an option but went with a list instead. Also as a final note I don't know if the price allows $ character but I left it and didn't see any errors.
0 notes
Link
So I created a Linux command for myself to setup websites rather by hand anymore. What took me 10 to 15 minutes now is just down to less then a minute where I can just pass parameters and go! This article is a place holder for the documentation and some notes so later if I need to create another command.
How it works... For the setup I have a setup start out checking for sudo and gain access because I'm going to modify a lot of folders. Taking the users input I add a file in Nginx first in sites-available then link it with sites-enabled. I pass the input in the file to have both the naked domain then the www version. From there its setting up a gitlab task-runner. Later down the road I might just convert everything to docker and might not need to setup a folder in /var. However for now I like this setup, so the last step is creating and pushing out the web service for the application. For now I do this last part manually because I have to test the package version and environment for now. Docker would fix these but it also forces me to use the same tech on the server and go through apps that I might not have touch for awhile. The service notes can be found on the Aspnet Dotnet Core Nginx documentation. Really this command is about automating that setup but I do have plans to expand on nodejs. location: /user/bin
site name
port
folder for /var/APP
I separate my apps based on their technology
Gitlab (yes or no)
then gitlab task-runner token
0 notes
Link
Started this in the beginning of the year... On a Friday night, I spent my time working up til 6 in the morning on this. Probably the most difficult but simple process I've completed. Still proud that I completed it in a single night despite all the challenges. Some of which actually helped me create a solution more professional in my opinion. Meaning I didn't just create a work around. For example in my research I found other developers using scp (secure copy in linux) with sshpass which isn't problem when deploying remotely. However I needed to do it locally. So for me using an ssh really seems waste for internal Processing. At the time creating this solution though I didn't care I need something fast. I should also note I'm not using docker to host my aspnetcore app but using the gitlab-runner in docker. Update to now I've come a long way now to where creating task runners is a lot easier and I'm spinning them up specifically for each project need. Where I can improve is mapping out what projects need what and what I can reuse. This might not be possible since I use a folder to map the docker image files out in the server's location. However if I used a parent folder and have a way to config the child folder that would reduce the amount of times I need to create a new task runner. That would also mean though that I'd have to group projects based on their technologies. A lot of my projects are based on open source projects on github. I do have a plan to combine some projects or handle them with a more api based backends. So this is really just a question of time and design with the api since I do use the same frontend technologies (if I can help it). Docker Images This is a list of images I can use when I'm attaching a new task runner. Most of my projects are dotcore but as I start to include more android projects this list will grow. Still in the middle with third parties on mobile development but doing more unit testings.
microsoft/dotnet
dotnet/core/sdk:2.1 (old version)
mcr.microsoft.com/dotnet/core/sdk:2.1
openjdk:8-jdk
0 notes
Link
Awhile back I moved to a new location for storing my server and for the most part things went smoothly. Didn't have any issues with my local DNS or emails, however I did encountered one issue. The issue was Recycled Motors where the application would boot but instantly fail. Which didn't create any logs or errors for me to look. So it took me a few weeks along with everything else going on to figure this one out. I spend a little too much time looking into my network and the bind9 configs because I know it had to do with my configs. Originally I was on a 10.0.10.x network but with the I.P. the modem only allowed the regular 192.168.1.x ip address. Eventually I figured out the issue, being my NLog config itself. I have it writing in a database where I list the ip address explictly. I completely forget about this since it was just a quick thing I added a few weeks before the move and I still have it pointed to localhost in the appsettings.json Solutions
Use different environment configs in the appsettings.json & nlog.config pull from there.
Use different environment configs for nlog.config (probably easy with the first idea)
I'll update this article later with my solution for now it is a ticket in my repo.
NOTES
https://stackoverflow.com/questions/43852104/unable-to-set-my-connectionstring-in-nlog
https://stackoverflow.com/questions/47413473/using-nlog-in-asp-net-core-2-0-web-application
https://github.com/NLog/NLog.Extensions.Logging/pull/248
NLog Tutorial for.NET Logging: 19 Best Practices and Tips
0 notes
Link
Currently working on a random list motorcycles to display on my front. At the moment don't have any priority listening on my site for clients other than the list of bikes I'm trying to sell personally as a source of income. For now this is what I did and its just these two parts to get things going.
something.OrderBy(r => Guid.NewGuid()).Take(3)
If you don't already have the extension this command will check and install for you.
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
0 notes
Link
When upgrading aspnet mvc applications I like to take a look on how I can convert the api's to async. This sometimes is really easy but as things get more complex my queries do as well. So this is a list of ways you can form a where clause on top your async but note not all solutions take advantage of it.
Notes on EFCore
Entity Framework Core provides a set of asynchronous extension methods that can be used as an alternative to the LINQ methods that cause a query to be executed and results returned. Examples include ToListAsync(), ToArrayAsync(), SingleAsync(), etc. There are not async versions of LINQ operators such as Where(...), OrderBy(...), etc. because these methods only build up the LINQ expression tree and do not cause the query to be executed in the database.
https://codereview.stackexchange.com/questions/32160/filtering-a-collection-by-an-async-result
Filtering a collection by an async result, built an extension method called WhereAsync.
public static async Task<IEnumerable<T>> WhereAsync2<T>(this IEnumerable<T> items, Func<T, Task<bool>> predicate) { var itemTaskList = items.Select(item=> new {Item = item, PredTask = predicate.Invoke(item)}).ToList(); await Task.WhenAll(itemTaskList.Select(x=>x.PredTask)); return itemTaskList.Where(x=>x.PredTask.Result).Select(x=>x.Item); }
https://forums.asp.net/t/1978783.aspx?Running+LINQ+to+SQL+query+async+
Running LINQ to SQL query async
Wrap with a task, Task.Run(() => { }
https://www.c-sharpcorner.com/UploadFile/4b0136/working-with-asynchronous-programming-with-entity-framework/
public async static Task<List<Student>> GetAllStudentsAsync()
{
MyDatabaseEntities db = new MyDatabaseEntities();
var query = from item in db.Students
select item;
return await query.ToListAsync();
}
Notes when looking at "include" in the docs they also don't show example with async...
https://social.msdn.microsoft.com/Forums/silverlight/en-US/a28dd0ba-e65b-4fd5-8099-ecc59eb30102/can-i-put-a-where-clause-on-my-include?forum=silverlightwcf
0 notes
Link
Last year I create a login page which I'm very happy to say I built it just how I wanted it. A rare thing if you've ever had to deal with management. Since the page only existed within sharepoint I want to keep things simple. So I went with jquery 2.x and bootstrap 3.3.7. Oldies But Goldies; so a few things I didn't want to create a lot of jquery code. So I had to really use the bootstrap collapsible component as much as I could without breaking it. Examples
Bootstrap PixKrh7Su5
Bootstrap Fdjc8kQiER
Disable collapse for link in a data-toggle element
You need to add a class for those elements that you don't want to fire the collapse event and then stop the event propagation via javascript. So... here is the correct answer.
<div class="panel panel-default"> <div class="panel-heading"> <div class="panel-title" data-toggle="collapse" href="#collapseOne"> <a href="#">1) collapsing link</a> <a href="#" class="no-collapsable">2) not collapsing link</a> </div> </div> <div id="collapseOne" class="panel-collapse collapse in"> <div class="panel-body">Anim pariatur cliche ...</div> </div> </div>
Stop the event propagation like this:
$('.no-collapsable').on('click', function (e) { e.stopPropagation(); });
0 notes
Link
If you haven't yet switch to using Access Tokens for your repo clone. Enable your Two-Factor Authentication and create an access token under your profile. I've done this with my gitlab and keep forgetting the quick way to update the path/command.
Go to https:///YOURGITLAB.com/profile/two_factor_auth
Then go to https:///YOURGITLAB.com/profile/personal_access_tokens
create a token with the api setting.
Now switching your remote url for your git is simple. Using this command..
git remote set-url origin http://USER:[email protected]/repo.git
If you have multiple origin urls you might have to remove them and add back an origin upstream and reset the origin master as the default upstream. This doesn't normally happen but I had a unique case where I had multiple urls for the origin where I was pushing to multiple repos for the same code. This probably won't be your case but I figure I might add this bit in.
0 notes
Link
Filtering By Nest Property
$scope.list = [ { 'Name': 'A', 'Manager': { 'Name': 'X' } }, { 'Name': 'B', 'Manager': { 'Name': 'X' } }, { 'Name': 'C', 'Manager': { 'Name': 'Y' } }]; <ul> <li ng-repeat="e in list | filter: {Manager: {Name: filter.key}}"> (Manager: ) </li> </ul>
Filter not equals
<li class="list-group-item" ng-repeat="question in Questions | filter:{ Id: '!-1'}"> <div href="#" editable-text="question.Text"></div> </li>
How to get key of the object? (not in the view)
The first parameter to the iterator in forEach is the value and second is the key of the object.
angular.forEach(objectToIterate, function(value, key) { /* do something for all key: value pairs */ });
In your example, the outer forEach is actually:
angular.forEach($scope.filters, function(filterObj , filterKey)
Example of GroupBy and Unique
<tr class="ng-cloak" ng-repeat="(key, value) in bl.notelist | groupBy: 'email'"> <td><span class="ng-cloak" ng-bind="value[0].email"></span></td> <td ng-repeat="player in value | unique:'appName'"> <label class="ng-cloak switch" title=""> <input type="checkbox" ng-checked="player.hasAccess" ng-disabled="!player.canModify"> </label> </td> </tr>
0 notes
Link
This Article is base ASP.Net Core 2 and the latest version of Nlog.
1. Install NLog and the Postgresql Package
Using NuGet to install the package into your ASP.NET Core project:
PM > Install-Package NLog.Web.AspNetCorePM > Install-Package Npgsql
3. Register NLog
Add in your Startup.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { ... env.ConfigureNLog("nlog.config"); ... // make sure Chinese chars don't fk up Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); //add NLog to ASP.NET Core loggerFactory.AddNLog(); //add NLog.Web app.AddNLogWeb(); }
4. Add to Your Controller
Add a logger object to your Controller.
private readonly ILogger<YourController> _logger;
Modify the constructor to use it
public YourController(ILogger<YourController> logger = null) { if (null != logger) { _logger = logger; } }
5. Use Logging APIs
Now, you can use the logging APIs like this:
_logger.LogInformation($"Created OrderId: {order.OrderId}, FriendlyId: {order.FriendlyId}, User: {user.UserName}.");
6. Using it with Postgresql
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Warn"
internalLogFile="C:\git\damienbod\AspNetCoreNlog\Logs\internal-nlog.txt">
<targets>
<target xsi:type="File" name="allfile" fileName="${gdc:item=configDir}\nlog-all.log"
layout="${longdate}|${event-properties:item=EventId.Id}|${logger}|${uppercase:${level}}|${message} ${exception}" />
<target xsi:type="File" name="ownFile-web" fileName="${gdc:item=configDir}\nlog-own.log"
layout="${longdate}|${event-properties:item=EventId.Id}|${logger}|${uppercase:${level}}| ${message} ${exception}" />
<target xsi:type="Null" name="blackhole" />
<target name="database" xsi:type="Database"
dbProvider="Npgsql.NpgsqlConnection, Npgsql"
connectionString="User ID=damienbod;Password=damienbod;Host=localhost;Port=5432;Database=log;Pooling=true;"
>
<!--
CREATE TABLE logs
(
Id serial primary key,
Application character varying(100) NULL,
Logged text,
Level character varying(100) NULL,
Message character varying(8000) NULL,
Logger character varying(8000) NULL,
Callsite character varying(8000) NULL,
Exception character varying(8000) NULL
)
-->
<commandText>
insert into logs (
Application, Logged, Level, Message,
Logger, CallSite, Exception
) values (
@Application, @Logged, @Level, @Message,
@Logger, @Callsite, @Exception
);
</commandText>
<parameter name="@application" layout="AspNetCoreNlog" />
<parameter name="@logged" layout="${date}" />
<parameter name="@level" layout="${level}" />
<parameter name="@message" layout="${message}" />
<parameter name="@logger" layout="${logger}" />
<parameter name="@callSite" layout="${callsite:filename=true}" />
<parameter name="@exception" layout="${exception:tostring}" />
</target>
</targets>
<rules>
<!--All logs, including from Microsoft-->
<logger name="*" minlevel="Trace" writeTo="allfile" />
<logger name="*" minlevel="Trace" writeTo="database" />
<!--Skip Microsoft logs and so log only own logs-->
<logger name="Microsoft.*" minlevel="Trace" writeTo="blackhole" final="true" />
<logger name="*" minlevel="Trace" writeTo="ownFile-web" />
</rules>
</nlog>
0 notes
Link
One of the many behaviors that I was asked recently to create was to allowing hide/show of the password and warn users that the locked character key is active. Since this solution could get complex and I just wanted to create a quick/simple demo and because of that I'm going to pick jquery. I could late come back and do it in another library but I already have a few ideas what I want to do. Notes:
input - Is it standard practice to indicate on the form that Caps Lock is on? - User Experience Stack Exchange
html5 - What's the difference between HTML 'hidden' and 'aria-hidden' attributes? - Stack Overflow
Examples:
Edit fiddle - JSFiddle
Better Passwords #3: Caps-lock Warnings — SitePoint
Code Bins : Password masking in jQuery
0 notes
Link
I'll be honest active directory has always been a difficult area for me to develop in. Which is why I prefer a basic user authorization that's just attached to the database. What I'm trying to do is leverage Oauth and inside pass in credentials to the active directory. Thous prevent users with the built in prompt and instead handle the authorization just like you would if it was inside an aspnet core Identity table. However this is no table! This means they can pass me any username and password. Not just what they are logged as under the domain (and under their browser). Very simple just difficult to explain with all the major buzz words floating around like Single Sign On, external service providers and etc. Which where I start to have trouble explain because I like to keep things simple. What my application will do is have an authorization page and redirect users to it if that are not logged in. Once I figure out they are who they say they are with the AD then continue as normal. Search under "Ldpa/Active Directory" This is probably the best place to start looking because as I was looking for examples, the mostly I could find was examples that had to do with windows as a external provider. Since I didn't want to just pass through the credentials but prompt the user under my own UI this wasn't help. Do I need IdentityServer4? Right now I think I do because of how I'm handling the provider with my client applications. I think its clear I could write something via the database with my personal project but I'm going to depend on active directory so I'm not responsible for user permissions. Notes:
http://docs.identityserver.io/en/release/topics/windows.html
https://stackoverflow.com/a/47438594/1265036: Solution
https://stackoverflow.com/questions/49682644/asp-net-core-2-0-ldap-active-directory-authentication
https://stackoverflow.com/questions/40986335/identityserver4-custom-authentication-with-active-directory
https://stackoverflow.com/questions/38736721/oauth-service-for-ldap-authentication
https://blogs.msdn.microsoft.com/dotnet/2017/11/16/announcing-the-windows-compatibility-pack-for-net-core
https://github.com/jusbuc2k/Justin.AspNetCore.LdapAuthentication
https://stackoverflow.com/questions/46729801/windows-authentication-does-not-accept-credentials: Example using claims
https://stackoverflow.com/questions/290548/validate-a-username-and-password-against-active-directory
0 notes
Link
This right I'm going naked on everything! Non-www and everything lowercase. Just to simplify my urls. If you couldn't write it out naturally or if it takes too long then I avoid making it a path. Special cases like unique guid url parameters being the exception. For the sites that have a ton parameters this its understandable but for the domains this rule really should be applied. In some cases might say the path is up to the application however if the framework doesn't handle this is a fall back.
https://superuser.com/questions/432674/nginx-remove-www-from-https
https://www.digitalocean.com/community/tutorials/how-to-redirect-www-to-non-www-with-nginx-on-ubuntu-14-04
http://nginx.org/en/docs/http/server_names.html
0 notes
Link
Most of the work I do for orchard is open source, this is because nothing other than content is property of my employer. Even if open source makes some employers uncomfortable a lot of my work is about success of a given project or the development process flow. In other words is everyone able to achieve what with the development or features created within a given project. That's just my take on things, I'm sure someone will disagree, putting security in a much higher priority. Which I think is a big part of my reason for being open source on the things I could improve unpon. Notes:
https://stackoverflow.com/questions/11149157/orchard-getting-the-contents-title-from-the-theme-layout
https://stackoverflow.com/questions/11688626/orchard-theme-placement-not-overriding-module-placement
https://stackoverflow.com/questions/13000711/add-individual-page-titles-to-html-document-head-in-orchard-cms
https://stackoverflow.com/questions/17737509/orchard-cms-custom-theme-every-page-displaying-title-and-date-stamp
asp.net - Orchard - Getting the Content's Title from the Theme Layout
0 notes
Link
This article is mostly on configuration with nginx and maybe a little on IIS.
Notes:
https://ift.tt/2geVQUT
https://ift.tt/2RlT4wG
https://ift.tt/2RlT4wG
https://ift.tt/2dwWPPs
https://ift.tt/168GKaE
0 notes
Link
Based on a gisthub configuration, which I thought was worth going through piece by piece.
https://gist.github.com/plentz/6737338
https://github.com/BIAndrews/nginx-compliance-config
HTTP2
https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-with-http-2-support-on-ubuntu-16-04
https://developers.google.com/web/tools/lighthouse/audits/http2
https://docs.microsoft.com/en-us/iis/get-started/whats-new-in-iis-10/http2-on-iis
Avoid If https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/ SSL Configuration
https://mozilla.github.io/server-side-tls/ssl-config-generator/
https://stackoverflow.com/questions/24594971/how-to-changehide-the-nginx-server-signature
Strict Transport Security (HSTS)
https://hstspreload.org/
https://www.nginx.com/blog/http-strict-transport-security-hsts-and-nginx/
https://en.wikipedia.org/wiki/DNS_Certification_Authority_Authorization
https://wiki.mozilla.org/Security/Server_Side_TLS#Modern_compatibility
0 notes