Skip to content

Instantly share code, notes, and snippets.

View brandedoutcast's full-sized avatar
🔥

R2 brandedoutcast

🔥
View GitHub Profile
@brandedoutcast
brandedoutcast / Loader.styl
Created January 29, 2018 13:19
Dead Simple Spin Loader
.loader
display flex
justify-content center
align-items center
&.fullscreen
min-height 100vh
&:after
content ""
@brandedoutcast
brandedoutcast / Randomize.cs
Created January 27, 2018 03:51
Generate random words & dates
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Models
{
public class Text
{
@brandedoutcast
brandedoutcast / hamburger nav menu toggle.styl
Last active April 21, 2019 18:18
Responsive pure css checkbox driven navigation menu with hamburger toggle animation
// <header>
// <input type="checkbox" id="menu-toggle" hidden checked="checked">
// <label for="menu-toggle">
// <span></span>
// </label>
// <span id="title"><a href="/">{{ .Title }}</a></span>
// <nav>
// <ul>
// <li><a href="#">Work</a></li>
// <li><a href="#">About</a></li>
@brandedoutcast
brandedoutcast / web-config.xml
Last active October 27, 2017 06:44
Web Config setting to remove / replace unwanted headers in response
<system.web>
<httpRuntime enableVersionHeader="false" />
</system.web>
<system.webServer>
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By" />
<remove name="X-AspNet-Version" />
<remove name="X-AspNetMvc-Version" />
<remove name="X-Powered-By-Plesk" />
@brandedoutcast
brandedoutcast / CacheFilterAttribtue.cs
Created October 27, 2017 02:05
Return Cache-Control response header in a Web API response
public class CacheFilterAttribute : ActionFilterAttribute
{
int DurationInSeconds = int.Parse(ConfigurationManager.AppSettings["CacheDuration"]);
public override Task OnActionExecutedAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken)
{
if (actionExecutedContext.Request.Method == HttpMethod.Get)
{
actionExecutedContext.Response.Headers.CacheControl = new CacheControlHeaderValue()
{
@brandedoutcast
brandedoutcast / StringSimilarity.cs
Last active December 9, 2019 13:00
Compare 2 strings & determine the similarity between them in percentage
public float SimilarityPercentage(string a, string b)
{
var SpecialCharacters = new Regex("[^\\w\\d\\s]");
a = SpecialCharacters.Replace(a, string.Empty);
b = SpecialCharacters.Replace(b, string.Empty);
var PairsInA = a.Split(' ').SelectMany(s => s.Zip(s.Substring(1), (fc, sc) => string.Concat(fc, sc)));
var PairsInB = b.Split(' ').SelectMany(s => s.Zip(s.Substring(1), (fc, sc) => string.Concat(fc, sc)));
@brandedoutcast
brandedoutcast / Google-OAuth-Token-Response.json
Created July 12, 2017 17:35
Google OAuth Exchange Auth Code for Refresh & Access Tokens Response
{
"access_token":"1/fFAGRNJru1FTz70BzhT3Zg",
"expires_in":3920,
"token_type":"Bearer",
"refresh_token":"1/xEoDL4iW3cxlI7yDbSRFYNG01kVKM2C-259HOF2aQbI"
}
@brandedoutcast
brandedoutcast / C# Fiddles
Last active November 19, 2016 02:52
Collection of quick run fiddles for reference
Generate timestamps from 00:00 to 23:59 (created to test with regex)
https://dotnetfiddle.net/6FI0Wo
Generate dates for an year
https://dotnetfiddle.net/fCccqO
@brandedoutcast
brandedoutcast / Regex Patterns
Last active November 19, 2016 15:33
General collection of Regular Expressions for reusability
Timestamp 12 & 24 hr format
(?:[0-1]?\d|2[0-3]):[0-5]?\d(?:pm|am)?
Timestamp 12 hr format
(?:0?\d|1[0-2]):[0-5]?\d\s?(?:pm|am)
Date format supporting yesterday, today & tomorrow along with delimeters -, / & space
(?:today|tomorrow|yesterday|(?:[0-2]?\d|3[0-1])(\s|-|\/)(?:0?\d|1[0-2])\1\d{4})
Decimal number > 1
@brandedoutcast
brandedoutcast / RemovePackages
Created February 20, 2016 18:45
Remove unwanted #NuGet packages from #MVC bloatware template
uninstall-package bootstrap
uninstall-package Modernizr
uninstall-package Respond
uninstall-package Microsoft.AspNet.Web.Optimization
uninstall-package WebGrease
uninstall-package Microsoft.jQuery.Unobtrusive.Validation
uninstall-package jQuery.Validation
uninstall-package jQuery
uninstall-package Microsoft.AspNet.Identity.EntityFramework
uninstall-package EntityFramework