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
Last active July 9, 2017 07:40 — forked from gistlyn/main.cs
What is going on?
var n = "1";
object value;
var hasDecimal = n.IndexOf('.') >= 0;
value = hasDecimal
? double.Parse(n)
: int.Parse(n);
System.Console.WriteLine($"{value} is {value.GetType().Name}");
@mythz
mythz / keyboard-shortcuts.ahk
Created June 27, 2017 01:03
Reprogram function keys to launch Apps or open URLs using AutoHotKey
;-----------------------------------------
; keyboard shortcuts using https://autohotkey.com/docs/AutoHotkey.htm
;=========================================
; --------------------------------------------------------------
; NOTES
; --------------------------------------------------------------
; ! = ALT
; ^ = CTRL
; + = SHIFT
@mythz
mythz / main.cs
Created May 12, 2017 14:01
Custom SQL with Custom Select Fields demo
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
Last active May 9, 2017 05:49
Image Place 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
Last active May 1, 2017 19:43
Batch JSON with Unix Time
using System;
using System.Collections.Generic;
using System.Linq;
using ServiceStack;
using ServiceStack.Text;
var json = @"
[
{
""speed"":34.52,
@mythz
mythz / main.cs
Last active April 29, 2017 13:17
Lambda Expression Issue
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using ServiceStack.DataAnnotations;
using ServiceStack.Model;
using ServiceStack.Text;
using ServiceStack.OrmLite;
using ServiceStack.OrmLite.Sqlite;
@mythz
mythz / main.cs
Last active April 6, 2017 03:01
Custom Left Self Join with adhoc WHERE query
using System;
using System.Collections.Generic;
using ServiceStack;
using ServiceStack.Logging;
using ServiceStack.Text;
using ServiceStack.OrmLite;
using ServiceStack.OrmLite.Sqlite;
using ServiceStack.DataAnnotations;
LogManager.LogFactory = new ConsoleLogFactory();
@mythz
mythz / main.cs
Last active April 6, 2017 02:10
OrmLite Complex Join Example
using System;
using System.Collections.Generic;
using ServiceStack;
using ServiceStack.Logging;
using ServiceStack.Text;
using ServiceStack.OrmLite;
using ServiceStack.OrmLite.Sqlite;
using ServiceStack.DataAnnotations;
LogManager.LogFactory = new ConsoleLogFactory();
@mythz
mythz / main.cs
Created March 18, 2017 18:14
AutoMapping Demo
using System.Collections.Generic;
using ServiceStack;
using ServiceStack.Text;
public enum Color { Red, Green, Blue }
public enum OtherColor { Red, Green, Blue }
public class SubModel
{
public string Name { get; set; }
@mythz
mythz / main.cs
Created February 28, 2017 21:14
Serialize Rectangle Example
using System.Linq;
using ServiceStack;
using ServiceStack.Text;
using System.Drawing;
JsConfig<Rectangle>.SerializeFn = r => $"{r.X},{r.Y},{r.Width},{r.Height}";
JsConfig<Rectangle>.DeSerializeFn = s => {
var parts = s.Split(',');
return new Rectangle(
int.Parse(parts[0]),