Skip to content

Instantly share code, notes, and snippets.

View minhhungit's full-sized avatar
😘
Hello world

Jin minhhungit

😘
Hello world
View GitHub Profile
@minhhungit
minhhungit / wakeupapp-homeassistant.cs
Created February 25, 2019 11:33 — forked from rille111/wakeupapp-homeassistant.cs
Example for a C# .NET Home-Assistant consuming app
using System.Threading.Tasks;
using NLog;
using Rille.Hass.ApiProxy;
using Rille.Hass.AppStarter;
using Rille.Hass.Models.StateChangeEventGraph;
namespace HassLab.Console.HassApps
{
public class WakeUpApp : IHassApp
{
@minhhungit
minhhungit / mongodb_c#_cheatsheet.md
Created July 18, 2019 12:34 — forked from a3dho3yn/mongodb_c#_cheatsheet.md
MongoDB C# Driver Cheat Sheet

MongoDB C# Driver Cheat Sheet

(C) 2015 by Derek Hunziker, (C) 2017 by AppsOn

As of releasing MongoDB 3.4 and C# Driver v2.4, original cheatsheet by Derek is outdated. In addition, it has some deficiencies like connecting to MongoDB, creating indexes, etc. This updated version works fine with C# Driver v2.4.7 and MongoDB v3.4.

Setup

Define Document Models

Note: Defined models and collections will be used in entire cheatsheet.

constructor() {
super();
let sdsAddFileBtn = this.form.Sds.element.find(".add-file-button");
let sdsClickEvt = (e) => {
e.preventDefault();
if (Q.trimToNull(Serenity.EditorUtils.getValue(this.form.Sds)) !== null) {
Q.confirm("This will overwrite the current file. Are you sure you want to continue?", () => {
// ~/Modules/Common/Helpers/MySlilerReveal.ts
namespace [PUT_YOUR_NAMESPACE_HERE].Common {
export class MySlilerRevealOptions {
grid: Serenity.DataGrid<any, any>;
dlg: Serenity.EntityDialog<any, any>;
onDataChangeCallback?: () => void;
sliderWidth?: any;
entityOrId?: any;
namespace YOUR_NAMESPACE.Common {
export class MySlilerRevealOptions {
target: JQuery;
initDialog: () => Serenity.EntityDialog<any, any>;
onDataChangeCallback?: () => void;
sliderWidth?: any;
entityOrId: any;
}
.s-Form label.caption {
margin-bottom: 2px;
text-align: left;
flex-basis: 100%;
}
.flex-layout .field {
flex-wrap: wrap;
}
namespace [YOUR_NAME_SPACE].Common {
export class MySliderRevealOptions {
initDialog: () => Serenity.EntityDialog<any, any>;
onDataChangeCallback?: () => void;
sliderWidth?: any;
entityOrId?: any;
// if we want to show next/previous buttons on slider
// then we also need to include grid data
@minhhungit
minhhungit / Dialog.ts
Created October 17, 2019 02:14
lookupeditor: pass parameters and change lookupkey
constructor() {
super();
this.form.MyOption.change(e => {
let currentValue = Serenity.EditorUtils.getValue(this.form.MyOption);
//let currentText = Serenity.EnumFormatter.format(MyEnum, Q.toId(currentValue));
//Q.notifySuccess(`You selected ${currentText}, lookup items will be reloaded`);
// clear old value
@minhhungit
minhhungit / 101-rx-samples.md
Created December 28, 2019 13:31 — forked from omnibs/101-rx-samples.md
101 Rx Samples in C#

101 Rx Samples in C#

This was taken from http://rxwiki.wikidot.com/101samples, because I wanted to be able to read it more comfortable with syntax highlighting.

Here's the unedited original, translated to Github Markdown glory:

101 Rx Samples - a work in progress

static ushort GetShardId(string key)
{
using var md5 = MD5.Create();
{
var hash = md5.ComputeHash(Encoding.UTF8.GetBytes(key));
var integer = BigInteger.Abs(new BigInteger(hash));
return (ushort)(integer % ushort.MaxValue);
}
}