Skip to content

Instantly share code, notes, and snippets.

View villian's full-sized avatar
🏠
Open to new opportunities

Oleksandr Skrypnyk villian

🏠
Open to new opportunities
View GitHub Profile
@villian
villian / CloudFlare Flexible SSL Redirect Loop on ASP.Net Umbraco nopCommerce website
Last active April 29, 2020 12:53
CloudFlare Flexible SSL Redirect Loop on ASP.Net Umbraco nopCommerce website. Cloudflare appends the CF-Visitor HTTP header as explained: <pre>CF-Visitor: {"scheme":"https"}</pre> For this reason, the respective web.config <rewrite> snippet which worked for us is the following:
<rewrite>
<rules>
<rule name="Redirect to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_CF_VISITOR}" pattern="(.*)https(.*)" ignoreCase="true" negate="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" redirectType="Permanent" />
</rule>
</rules>
@villian
villian / Linkedin: Accept all pending invitations, run in browser console
Created May 5, 2020 17:08
Linkedin: Accept all pending invitations, run in browser console
var x = document.getElementsByClassName('invitation-card__action-btn artdeco-button'); for (var i=0 ;
i<x.length; i++) x[i].click();
@villian
villian / Umbraco 7: Cleaning out UrlTracker
Created August 31, 2020 22:14
Umbraco 7: Cleaning out UrlTracker
SET NOCOUNT ON;
DECLARE @r INT;
SET @r = 1;
WHILE @r > 0
BEGIN
BEGIN TRANSACTION;
@villian
villian / Bootstrap.cs
Created October 16, 2020 14:39 — forked from mattbrailsford/Bootstrap.cs
Indexing JSON values in Umbraco
public class Bootstrapper : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
base.ApplicationStarted(umbracoApplication, applicationContext);
ExamineManager.Instance.IndexProviderCollection["ExternalIndexer"]
.GatheringNodeData += (sender, e) =>
{
// Extract JSON properties

Disable HTML Form Input Autocomplete and Autofill

  1. Add autocomplete="off" onto <form> element;
  2. Add hidden <input> with autocomplete="false" as a first children element of the form.
<form autocomplete="off" method="post" action="">
    <input autocomplete="false" name="hidden" type="text" style="display:none;">
    ...
@villian
villian / controller.cs
Created December 13, 2020 12:33
c# mvc Recaptcha
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Contact(ContactModel model)
{
var response = Request["g-recaptcha-response"];
string secretKey = ""; // Ur secretKey
var webClient = new WebClient();
var result = webClient.DownloadString(string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", secretKey, response));
var obj = JObject.Parse(result);
var status = (bool)obj.SelectToken("success");
@villian
villian / index.html
Created February 18, 2021 23:33 — forked from paulozoom/index.html
Async non-render-blocking loading of cloud.Typography’s typefaces
<!-- loadCSS with async -->
<script async="async" src="/assets/loadcss.js" type="text/javascript"></script>
<!-- preload the fonts -->
<link as="style" href="https://cloud.typography.com/[…].css" onload="this.rel='stylesheet'" rel="preload" />
<!-- non-JS fallback -->
<noscript>
<link href="https://cloud.typography.com/[…].css" media="screen" rel="stylesheet" type="text/css" />
</noscript>
public class ProductComponent : IComponent
{
private readonly IExamineManager _examineManager;
private readonly ProductIndexCreator _productIndexCreator;
public ProductComponent (IExamineManager examineManager, ProductIndexCreator productIndexCreator)
{
_examineManager = examineManager;
_productIndexCreator = productIndexCreator;
}
@villian
villian / SMTP.aspx
Created January 20, 2022 00:47 — forked from rasmuseeg/SMTP.aspx
Simple SMTP test aspx page for sending and testing smtp configuration and server response.
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.Net.Mail" %>
<%@ Import Namespace="System.Net.Sockets" %>
<%@ Import Namespace="System.Net.Security" %>
<%@ Import Namespace="System.Net.Configuration" %>
<%@ Import Namespace="Umbraco.Core.Configuration" %>
<%@ Page Language="C#" %>
@villian
villian / Umbraco9Images.cshtml
Created April 27, 2022 21:33 — forked from brendan-rice/Umbraco9Images.cshtml
Responsive, high performance images in umbraco 9
@* /Views/Partials/ResponsiveImage.cshtml *@
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
@using Umbraco.Cms.Core.Media
@using Umbraco.Cms.Core.Models.PublishedContent
@using Umbraco.Cms.Core.Routing
@inject IPublishedValueFallback PublishedValueFallback
@inject IPublishedUrlProvider PublishedUrlProvider
@inject IImageUrlGenerator ImageUrlGenerator
@{