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;
}
@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
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);
}
}
@minhhungit
minhhungit / J.ToolDropdownButton.ts
Last active August 10, 2020 12:03
serenity-toolbar-dropdown-button
//===================================================
// Copyright @ 2020
// Author : Hung Vo (it.minhhung@gmail.com)
// Time : 2020, June 10
// Description : ToolDropdownButton
//===================================================
namespace J {
export interface ToolDropdownButtonOptions {
title?: string;
cssClass?: string;
@minhhungit
minhhungit / J.HelpPopover.ts
Last active August 10, 2020 17:00
bootstrap-popover-with-serenity-form
/* Modules/Common/Helpers/J.HelpPopover.ts */
//===================================================
// Copyright @ 2020
// Author : Hung Vo (it.minhhung@gmail.com)
// Time : 2020, August 06
// Description : HelpPopover
//===================================================
namespace J {