Skip to content

Instantly share code, notes, and snippets.

View romeshniriella's full-sized avatar
🎯
Building blockchain infrastructure

Romesh Niriella romeshniriella

🎯
Building blockchain infrastructure
  • Melbourne, VIC, AU
View GitHub Profile
@romeshniriella
romeshniriella / BookingItemReorderHelper.cs
Created February 3, 2017 07:18
Reorder a list of items based on a predefined criteria
public static class BookingItemReorderHelper
{
public static Dictionary<DateTime, List<SimpleBookingItem>> Reorder(Dictionary<DateTime, List<SimpleBookingItem>> dates)
{
foreach (var date in dates)
{
var temp = date.Value.Reorder();
date.Value.Clear();
date.Value.AddRange(temp);
@romeshniriella
romeshniriella / FileManager.cshtml
Last active January 28, 2017 11:04
How to create a .NET Core MVC File Uploader Module
@using ARCode.Web.Areas.Admin.Models.Components
@model ARCode.Web.Areas.Admin.Models.Components.FileSelectorSettings
<div class="btn-group" role="group" aria-label="...">
@if (Model.EnableFileSelect)
{
<button class="btn @Model.FileSelectButtonCssClass " data-toggle="modal" data-target="#@(Model.FileSelectIdPrefix)FileSelectModal">@Html.Raw(Model.FileSelectButtonText)</button>
}
@if (Model.EnableFileUpload)
{
@romeshniriella
romeshniriella / GroupingHelper.cs
Created October 3, 2016 19:00
Group an array into a list of array of n elements each
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Helpers
{
/// ref: http://stackoverflow.com/a/3514775/959245
public static class GroupingHelper
{
@romeshniriella
romeshniriella / AuthToken.cs
Last active April 2, 2025 10:13
Token Authentication C# Console Application - Sample
using Newtonsoft.Json;
internal sealed class AuthToken
{
[JsonProperty("access_token")] // using Newtonsoft.Json => JsonProperty;
public string AccessToken { get; set; }
[JsonProperty("token_type")]
public string TokenType { get; set; }
@romeshniriella
romeshniriella / CreateBookingCommandHandler.cs
Last active April 10, 2016 11:38
Commands, Queries and Decorators
using System.Linq;
using System.Threading.Tasks;
using Oklo.BookingService.Core.Booking.Data.Responses;
using Oklo.BookingService.Core.Booking.Engine;
using Oklo.BookingService.Core.Exceptions;
using Oklo.BookingService.Domain.Models.Booking;
using Oklo.BookingService.Domain.Models.Commands;
using Oklo.BookingService.Domain.Models.Results;
using Oklo.Core.Framework.Commands;
using Oklo.Core.Utils.Extensions;
@romeshniriella
romeshniriella / JQValidate attr Rule List.txt
Created April 8, 2016 16:55
html attribute validators
Credits/Ref: http://johnnycode.com/2014/03/27/using-jquery-validate-plugin-html5-data-attribute-rules/
(Tested, core)
data-rule-required="true"
data-rule-email="true"
(Untested, core, but should work)
data-rule-url="true"
data-rule-date="true"
package com.esoftdive.core.smpp.internal;
import java.util.Random;
import com.cloudhopper.commons.charset.CharsetUtil;
import com.cloudhopper.smpp.SmppConstants;
import com.cloudhopper.smpp.SmppSession;
import com.cloudhopper.smpp.pdu.SubmitSm;
import com.cloudhopper.smpp.type.Address;
/// <summary>
/// A listing of ASCII control characters for readability.
/// </summary>
public static class AsciiControlChars
{
/// <summary>
/// Usually indicates the end of a string.
/// </summary>
public const char Nul = (char)0x00;
@romeshniriella
romeshniriella / Audit Sample XML.xml
Last active November 23, 2015 11:32
a sample sql trigger for inserting a new audit record to audit table when a IUD operation is done on a table
<!-- this is a sample XML generated by the trigger -->
<dbo.TestGroup>
<row user="romeshnr" type="U" timestamp="2015-11-23T10:06:30.913">
<TestGroupID>1</TestGroupID>
<Name old="Performance" new="System Performance" /> <!-- notice the update -->
</row>
<row user="dirnthelord" type="U" timestamp="2015-11-23T10:06:30.913">
<TestGroupID>6</TestGroupID> <!-- user tried to update without any changes! -->
</row>
/// <summary>
/// Bind the alias to relevant property so that incoming property name and JSON serialized property name will be different.
/// </summary>
/// <remarks>
/// The reason for not using <see cref="Newtonsoft.Json.Serialization.JsonProperty"/> is that when serialized, property name
/// is not the one we defined in our class.
/// for BindAlias class see here: https://github.com/schotime/SchoStack/blob/master/SchoStack.Web/AliasBinding.cs
/// </remarks>
[ModelBinder(typeof(AliasApiModelBinder<HotelSearchParameters>))]
public class HotelSearchParameters