Skip to content

Instantly share code, notes, and snippets.

@zmts
zmts / tokens.md
Last active March 5, 2025 15:04
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@tystol
tystol / PostalEmailService.cs
Last active June 30, 2020 08:34
Postal Emails with layouts outside a http request context. There's a few application specific interfaces in here, but should be fairly easy to strip out and adapt.
public class PostalEmail<T> : Email where T : IEmail
{
public PostalEmail(string viewName, T model)
: base(viewName)
{
To = model.To;
Email = model;
}
public string To { get; private set; }
@akhoury
akhoury / handlebars-helper-x.js
Last active February 17, 2024 13:25
Handlebars random JavaScript expression execution, with an IF helper with whatever logical operands and whatever arguments, and few more goodies.
// for detailed comments and demo, see my SO answer here http://stackoverflow.com/questions/8853396/logical-operator-in-a-handlebars-js-if-conditional/21915381#21915381
/* a helper to execute an IF statement with any expression
USAGE:
-- Yes you NEED to properly escape the string literals, or just alternate single and double quotes
-- to access any global function or property you should use window.functionName() instead of just functionName()
-- this example assumes you passed this context to your handlebars template( {name: 'Sam', age: '20' } ), notice age is a string, just for so I can demo parseInt later
<p>
{{#xif " name == 'Sam' && age === '12' " }}
BOOM
@danmusk
danmusk / ElmahMigration.cs
Last active April 4, 2016 14:40
EF Migrations for Elmah. Include sql for Elmah in Azure (by Roberto Bonini).
public partial class Elmah : DbMigration
{
public override void Up()
{
Sql(CreateTable_ELMAH_Error);
Sql(CreatreProcedure_ELMAH_GetErrorXml);
Sql(CreateProcedure_ELMAH_GetErrorsXml);
Sql(CreateProcedure_ELMAH_LogError);
}
@chrisl8888
chrisl8888 / drupal-views-share-global-text-field
Last active April 23, 2024 04:07
share url's for facebook, twitter, pinterest with just get variables
<ul>
<li class="share-text">Share this>/li>
<li class="share-tw"><a href="http://twitter.com/share?text=[title]"><span></span></a></li>
<li class="share-fb"><a href="http://www.facebook.com/sharer.php?u=/node/[nid]&p=[title]"><span></span></a></li>
<li class="share-pinterest"><a href="http://pinterest.com/pin/create/button/?url=/node/[nid]&description=[title]"><span></span></a></li>
</ul>