Skip to content

Instantly share code, notes, and snippets.

Avatar

Demis Bellot mythz

View GitHub Profile
@mythz
mythz / vanilla.js
Created Jan 19, 2021
3 missing JS functions
View vanilla.js
let $ = sel => document.querySelector(sel),
$$ = sel => document.querySelectorAll(sel);
function on(sel, handlers) {
$$(sel).forEach(e => {
Object.keys(handlers).forEach(function (evt) {
let fn = handlers[evt];
if (typeof evt === 'string' && typeof fn === 'function') {
e.addEventListener(evt, fn.bind(e));
}
@mythz
mythz / main.cs
Last active Dec 2, 2020
Custom SQL Issue
View main.cs
using System;
using System.Linq;
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 Nov 23, 2020
Ensures with Dynamic SqlExpression Example
View main.cs
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(); // view generated SQL
OrmLiteConfig.StripUpperInLike = true; // comment to force insensitive like comparisons
@mythz
mythz / main.cs
Created Oct 19, 2020
Create new JWT Auth Key
View main.cs
var base64Key = System.Convert.ToBase64String(ServiceStack.AesUtils.CreateKey());
System.Console.WriteLine(base64Key);
@mythz
mythz / main.cs
Created Jul 1, 2020 — forked from alfredoPacheco/main.cs
Redis Redis/Memory RemoveAll repro
View main.cs
using System;
using ServiceStack;
using ServiceStack.Text;
using ServiceStack.Redis;
using ServiceStack.DataAnnotations;
using ServiceStack.Caching;
var redisManager = new RedisManagerPool("localhost:6379");
var redis = redisManager.GetClient();
redis.FlushAll();
@mythz
mythz / main.cs
Last active Jun 29, 2020
Redis RemoveAll repro
View main.cs
using System;
using ServiceStack;
using ServiceStack.Text;
using ServiceStack.Redis;
using ServiceStack.DataAnnotations;
var redisManager = new RedisManagerPool("localhost:6379");
var redis = redisManager.GetClient();
redis.FlushAll();
@mythz
mythz / main.cs
Created May 14, 2020
Using custom Guid in JSON
View main.cs
using System;
using System.Linq;
using ServiceStack;
using ServiceStack.Text;
JsConfig<Guid>.SerializeFn = guid => guid.ToString();
public partial class Dto
{
public Guid Guid { get; set; } = Guid.NewGuid();
@mythz
mythz / main.cs
Created Mar 28, 2020 — forked from gistlyn/main.cs
OrmLite runtime attributes
View main.cs
using System;
using System.Collections.Generic;
using ServiceStack;
using ServiceStack.Text;
using ServiceStack.OrmLite;
using ServiceStack.OrmLite.Sqlite;
using ServiceStack.DataAnnotations;
OrmLiteUtils.PrintSql();
var dbFactory = new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider);
@mythz
mythz / main.cs
Created Aug 6, 2019
Create Project Table Test
View main.cs
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 Jul 10, 2019 — forked from sashapodgoreanu/main.cs
Auto Mapping Converter Example
View main.cs
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;