Skip to content

Instantly share code, notes, and snippets.

@mota57
mota57 / Helper.cs
Last active September 25, 2019 12:58
SqlkataExtensions
public static class ConvertHelper
{
//https://stackoverflow.com/questions/425389/c-sharp-equivalent-of-sql-server-datatypes
private static readonly Dictionary<string, string> DotNetMappingSqlServer = new Dictionary<string, string> {
{ "Byte[]", "VARBINARY" } ,
{ "Byte", "BINARY" } ,
{ "Boolean", "BIT" } ,
{ "Char", "nvarchar(1)" } ,
{ "DateTime", "DATETIME" } ,
{ "Decimal", "DECIMAL" } ,
@mota57
mota57 / Review.cs
Last active November 26, 2018 20:57
example of entity framework deleting recursively self reference table comment/review
public class Entity
{
public Guid Id { get; set; }
public string Name { get; set; }
public DateTime? CreateDate { get; set; }
public DateTime? LastUpdate { get; set; }
public bool IsActive { get; set; }
public bool Deleted { get; set; }
}
@mota57
mota57 / CheckboxExample.cs
Last active October 3, 2018 10:07
angularjs checkboxes submit post without ajax. asp.net mvc 4
public class MenuItem
{
public int Id {get; set;}
public string Name {get; set;}
public IEnumerable<MenuItem> MenuItems {get;set;}
}
@mota57
mota57 / BaseRepository.cs
Last active September 3, 2018 14:36
example of a base repository example
public interface IModelClass
{
public Guid Id {get; set;}
}
public class BaseRepository<TEntity, TDto> : IRepository<TEntity, TDto>
where TEntity : class, IModelClass
where TDto :class, IModelClass
{
@mota57
mota57 / flat.arrayv3.js
Last active September 9, 2018 13:12
Simple Flat Array
var FlatArray = (function(){
var vm = this;
vm.row = [];
function CallFlatFunction(inputs)
{
var result = FlatFunction(inputs);
vm.row = [];
return result;
}
@mota57
mota57 / MyCalculator.js
Last active September 6, 2021 16:57
simple javascript calculator
var PlainCalculator = (function() {
const ExpressionSide = {
LEFT: 0,
RIGHT:2
};
const ExpressionType = {
NUMBER: 0,
@mota57
mota57 / nginxproxy.md
Created May 16, 2018 19:37 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@mota57
mota57 / Get query string value.
Last active October 26, 2017 23:48
Useful and minimal function to get the values of the query string. Not jQuery or dependency need it
var getQueryVal = function(str) {
s = window.location.href;
var regexstr = new RegExp(str+'=','i');
if (s.indexOf('?') !== -1) {
var result = s.substr(s.indexOf('?')+1,s.length).split('&').find(x => x.match(regexstr));
if(result){
return result.split('=')[1];
}else{
function findTByKeyValue (element, target){
var found = true;
for(var key in target) {
if (!element.hasOwnProperty(key) || element[key] !== target[key]) {
found = false;
break;
}
}
if(found) {
@mota57
mota57 / tmux-cheatsheet.markdown
Last active August 29, 2015 14:27 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname