Skip to content

Instantly share code, notes, and snippets.

View mythz's full-sized avatar

Demis Bellot mythz

View GitHub Profile
@mythz
mythz / main.cs
Created August 6, 2019 19:16
Create Project Table Test
using System;
using ServiceStack;
using ServiceStack.Text;
using ServiceStack.OrmLite;
using ServiceStack.OrmLite.Sqlite;
using ServiceStack.DataAnnotations;
var dbFactory = new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider);
var db = dbFactory.Open(); // Open ADO.NET DB Connection
OrmLiteUtils.PrintSql();
@mythz
mythz / main.cs
Created July 10, 2019 15:32 — forked from sashapodgoreanu/main.cs
Auto Mapping Converter Example
using System;
using System.Linq;
using ServiceStack;
using ServiceStack.Text;
using System.Collections.Generic;
AutoMapping.RegisterConverter((CarRevisionDbo from) => {
var to = from.ConvertTo<CarRevisionDto>(skipConverters:true);
to.PopulateWith(from.Car);
return to;
@mythz
mythz / main.cs
Last active June 19, 2019 20:13
OrmLite 1:Many projection demo
using System;
using System.Collections.Generic;
using ServiceStack;
using ServiceStack.Text;
using ServiceStack.OrmLite;
using ServiceStack.OrmLite.Sqlite;
using ServiceStack.DataAnnotations;
var dbFactory = new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider);
var db = dbFactory.Open(); // Open ADO.NET DB Connection
@mythz
mythz / main.cs
Created May 7, 2019 20:05
OrmLite Self Reference Example
using System;
using ServiceStack;
using ServiceStack.Text;
using ServiceStack.OrmLite;
using ServiceStack.OrmLite.Sqlite;
using ServiceStack.DataAnnotations;
var dbFactory = new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider);
var db = dbFactory.Open(); // Open ADO.NET DB Connection
@mythz
mythz / main.cs
Created April 23, 2019 21:33
Test string DeSerilizeFn
using System.Linq;
using ServiceStack;
using ServiceStack.Text;
JsConfig<string>.DeSerializeFn = str => str?.Trim();
public class Test
{
public string Name { get; set; }
public string Age { get; set; }
@mythz
mythz / main.cs
Created April 8, 2019 06:58
SqlExpressionSelectFilter JoinAlias
using ServiceStack;
using ServiceStack.Text;
using ServiceStack.OrmLite;
using ServiceStack.OrmLite.Sqlite;
using ServiceStack.DataAnnotations;
var dbFactory = new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider);
var db = dbFactory.Open(); // Open ADO.NET DB Connection
OrmLiteUtils.PrintSql();
@mythz
mythz / main.cs
Created April 7, 2019 20:19
CSV Serialize Test
using System;
using System.Linq;
using System.Collections.Generic;
using ServiceStack;
using ServiceStack.Text;
class ListEntry
{
public ListEntry(string a, string b)
{
@mythz
mythz / main.cs
Created March 30, 2019 00:48
Custom Self Reference Conventions
using ServiceStack;
using ServiceStack.Text;
using ServiceStack.OrmLite;
using ServiceStack.OrmLite.Sqlite;
using ServiceStack.DataAnnotations;
var dbFactory = new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider);
var db = dbFactory.Open(); // Open ADO.NET DB Connection
public class CustomerAddress
@mythz
mythz / ss-require.js
Created February 23, 2019 04:41
Minimal AMD define()
var EXPORT = { vue: 'Vue' };
window.define = function (name, deps, f) {
var anon = typeof name != "string";
if (anon) {
f = deps;
deps = name;
}
if (typeof deps == "function") {
f = deps;
deps = [];
@mythz
mythz / binary-search.coffee
Created September 13, 2011 19:09
Side by Side: CoffeeScript vs JavaScript - Algorithms Edition
# All CoffeeScript examples from: https://github.com/jashkenas/coffee-script/blob/master/examples/computer_science/
# All Java Script examples from: https://github.com/nzakas/computer-science-in-javascript - Copyright (c) 2009 Nicholas C. Zakas
# - Released under https://github.com/nzakas/computer-science-in-javascript/blob/master/LICENSE (*.js copyright headers reduced for clarity)
# Uses a binary search algorithm to locate a value in the specified array.
binary_search = (items, value) ->
start = 0