Skip to content

Instantly share code, notes, and snippets.

View Xordal's full-sized avatar

Luzhbin Denis Xordal

  • Russia, Taganrog
View GitHub Profile
@Xordal
Xordal / request.json
Created September 6, 2018 17:23
joi arrays validation
{
"cart_id": 56,
"drugs": [
{
"id": 8,
"count": 2
},
{
"id": 456,
"count": 0
@Xordal
Xordal / BaseApiController.cs
Last active February 28, 2018 15:13
RoutePrefix for BaseController inheritance with versioning
[System.Web.Http.Authorize]
[ApiVersion("1.0")]
[RoutePrefix("api/v{version:apiVersion}")]
public class BaseApiController : ApiController
@Xordal
Xordal / EnumHelper.cs
Created September 21, 2016 12:47
Get display name for enum
namespace Model.Enums
{
using System;
using System.ComponentModel.DataAnnotations;
using System.Reflection;
public static class EnumHelper<T>
{
private static String LookupResource(Type resourceManagerProvider, String resourceKey)
{
@Xordal
Xordal / password
Last active September 5, 2016 10:50
Regexp: password validation
// minimum: one digit, one Uppercase, one Lowercase
(?=.*\d)(?=.*\p{Lu})(?=.*\p{Ll})(.|D){6,}
// 6 - minimum length
for c#:
String pattern = @"^(?=.*\d)(?=.*\p{Lu})(?=.*\p{Ll}).{6,}$";
@Xordal
Xordal / TaskBuilder.cs
Last active September 30, 2020 17:03
TaskBulder for TPL in MVC4
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Utils
{
using System.Threading;
public interface ITaskBuilder
@Xordal
Xordal / Regexp: string not contain substring
Last active August 29, 2015 14:19
Regexp: string not contain substring
regular: (?:(?!med).)
Example:
regular: a(?:(?!med).)*bb
data: amada, admeta, medbbsasdfbb
result: , , asdfbb
@Xordal
Xordal / weekNum.cs
Created September 22, 2014 06:16
Week of year
const CalendarWeekRule WeekRule = CalendarWeekRule.FirstFourDayWeek;
const DayOfWeek FirstWeekDay = DayOfWeek.Monday;
var calendar = System.Threading.Thread.CurrentThread.CurrentCulture.Calendar;
var currentWeek = calendar.GetWeekOfYear(curDateTime, WeekRule, FirstWeekDay);
@Xordal
Xordal / singleDoubleClick.js
Created July 7, 2014 12:28
Single- and double-click functions
jQuery.fn.single_double_click = function(single_click_callback, double_click_callback, timeout) {
return this.each(function() {
var clicks = 0, self = this;
jQuery(this).click(function(event) {
clicks++;
if (clicks == 1) {
setTimeout(function() {
if (clicks == 1) {
single_click_callback.call(self, event);
} else {
@Xordal
Xordal / invertRGB.js
Created July 7, 2014 12:26
Invert RGB color js
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
function rgbToHex(r, g, b) {
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}
function invert(rgb) {
@Xordal
Xordal / Layout.html
Created January 15, 2014 05:45
Multiple versions of jQuery on the same page
<script type='text/javascript' src='@Url.Content( "~/Scripts/jquery-1.5.1.js" )'></script>
<script type="text/javascript">
$(selector).dosome(); // for use 1.5.1 jquery
</script>