Skip to content

Instantly share code, notes, and snippets.

View chinhvo's full-sized avatar

Chinh Vo Wili chinhvo

View GitHub Profile
@chinhvo
chinhvo / JSONWriteRead.cs
Created May 26, 2021 06:42 — forked from samilkorkmaz/JSONWriteRead.cs
C# JSON save to and load from file
[DataContract]
public class UserInputs
{
[DataMember]
internal string ServerName;
[DataMember]
internal string IpAddress;
[DataMember]
internal int Port;
}
@chinhvo
chinhvo / DataExportClass.cs
Created May 25, 2021 07:36 — forked from luisdeol/DataExportClass.cs
Export List of Objects to a Comma-Separated Values (.CSV) file using C#, allowing the export of Entity Framework DbSet to CSV File. An example of use comes within the code.
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace DataExportClass
{
class Program
{
public class Employee
@chinhvo
chinhvo / drop-zone-directive.ts
Created May 20, 2021 07:35 — forked from darrenmothersele/drop-zone-directive.ts
Angular Drag and Drop File Directive
import { Directive, EventEmitter, HostBinding, HostListener, Input, Output } from '@angular/core';
// Angular Drag and Drop File
//
// Add this directive to an element to turn it into a dropzone
// for drag and drop of files.
// Example:
//
// <div (appDropZone)="onDrop($event)"></div>
//
@chinhvo
chinhvo / UCMA UserEndpoint Sending IM Example.cs
Created May 12, 2021 08:04 — forked from tomorgan/UCMA UserEndpoint Sending IM Example.cs
Simplest example using UCMA UserEndpoint to send an IM. Note: no error handling, assumes IM always accepted etc. For learning only :)
using Microsoft.Rtc.Collaboration;
using System;
namespace SimpleUserUCMA
{
class Program
{
private const string sipaddress = "sip:[email protected]";
private const string username = "USERNAME";
private const string password = "PASSWORD";
@chinhvo
chinhvo / completion-suggester.cs
Created May 11, 2021 04:29 — forked from russcam/completion-suggester.cs
Using Completion Suggester with NEST
void Main()
{
var indexName = "stackoverflow";
var node = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var settings = new ConnectionSettings(node)
.InferMappingFor<Question>(m => m
.IndexName(indexName)
)
.PrettyJson()
.DisableDirectStreaming()
@chinhvo
chinhvo / custom-schedule.component.ts
Created March 9, 2021 06:47 — forked from AilisObrian/custom-schedule.component.ts
PrimeNG's Schedule Component refactored for overriding FullCalendar's configs @ ngOnInit().
import {
Component,
ElementRef,
IterableDiffers,
OnInit,
Input,
Output,
EventEmitter,
} from '@angular/core';
import { Schedule } from 'primeng/primeng';
@chinhvo
chinhvo / colliding.js
Created January 21, 2021 07:43 — forked from jtsternberg/colliding.js
Detect if two elements are colliding/overlapping
/**
* Detects if two elements are colliding
*
* Credit goes to BC on Stack Overflow, cleaned up a little bit
*
* @link http://stackoverflow.com/questions/5419134/how-to-detect-if-two-divs-touch-with-jquery
* @param $div1
* @param $div2
* @returns {boolean}
*/
@chinhvo
chinhvo / ParentChild.es6
Created January 3, 2021 07:05 — forked from sebkouba/ParentChild.es6
Basic example to pass values between parent and child components in React.
/**
* Basic example to pass values between parent and child components in React
* Seems to be in line with this
* http://stackoverflow.com/questions/24147331/react-the-right-way-to-pass-form-element-state-to-sibling-parent-elements
* Now I have the state in parent and child. Is that good or bad? Why would I need it in child?
* Could probably take that out
* */
class Parent extends React.Component {
constructor(props) {
super(props);
@chinhvo
chinhvo / Context.tt
Created December 26, 2020 14:42 — forked from mikecole/Context.tt
Context T4 template used by Reverse Engineer Code First - After
<#@ template hostspecific="true" language="C#" #>
<#@ include file="EF.Utility.CS.ttinclude" #><#@
output extension=".cs" #><#
var efHost = (EfTextTemplateHost)Host;
var code = new CodeGenerationTools(this);
#>
using System.Data.Entity;
using <#= code.EscapeNamespace(efHost.MappingNamespace) #>;
@chinhvo
chinhvo / check_sorted.js
Created September 21, 2020 03:18 — forked from yorkie/check_sorted.js
Check if an array is sorted in Javascript...
/*
* check the array is sorted
* return: if positive -> 1
* if negative -> -1
* not sorted -> 0
*/
Array.prototype.isSorted = function() {
return (function(direction) {
return this.reduce(function(prev, next, i, arr) {