Skip to content

Instantly share code, notes, and snippets.

View daonhan's full-sized avatar
🎯
Focusing

Paul Nhan Nguyen Dao daonhan

🎯
Focusing
View GitHub Profile
@daonhan
daonhan / TextFileEncodingDetector.cs
Last active August 29, 2015 14:26 — forked from TaoK/TextFileEncodingDetector.cs
Simple class to automatically detect text file encoding, with English-biased "best guess" heuristic based on byte patterns in the absence of BOM.
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
namespace KlerksSoft
{
public static class TextFileEncodingDetector
{
/*
@daonhan
daonhan / app.component.ts
Created July 22, 2016 01:36 — forked from StephenFluin/app.component.ts
Angular 2 Analytics via Routing
//...
import { Router, NavigationEnd } from '@angular/router';
//...
declare var ga : any;
//..
constructor(private router : Router ) {
router.events.filter(e => e instanceof NavigationEnd).subscribe( (n:NavigationEnd) => {
@daonhan
daonhan / ngrxintro.md
Created July 19, 2017 02:06 — forked from btroncone/ngrxintro.md
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

@daonhan
daonhan / introrx.md
Created August 5, 2017 05:30 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@daonhan
daonhan / imageRotate.js
Created July 17, 2018 03:55 — forked from seungjin/imageRotate.js
image ratate javascript (rotate image 90 degree....)
/* image rotate javascript */
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Benoit Asselin | http://www.ab-d.fr */
function rotate(p_deg) {
if(document.getElementById('canvas')) {
/*
Ok!: Firefox 2, Safari 3, Opera 9.5b2
@daonhan
daonhan / app.js
Created May 23, 2019 08:34 — forked from dskanth/app.js
Server file for Private chat using node.js and socket.io
var app = require('express').createServer()
var io = require('socket.io').listen(app);
var fs = require('fs');
app.listen(8008);
// routing
app.get('/', function (req, res) {
res.sendfile(__dirname + '/chat.html');
});
@daonhan
daonhan / chat.html
Created May 23, 2019 09:18 — forked from dskanth/chat.html
Client file for Private chat using node.js and socket.io
<script src="/socket.io/socket.io.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript">
var my_username = '';
function send_individual_msg(id)
{
//alert(id);
//alert(my_username);
socket.emit('check_user', my_username, id);
//socket.emit('msg_user', id, my_username, prompt("Type your message:"));
const stream = require('stream')
const cache = new Map() // you might wanna use an lru here
function createCacheStream (url) {
const buf = []
return stream.Transform({
transform: function (data, enc, cb) {
buffer.push(data)
cb(null, data)
},
package auth
import (
"context"
"net/http"
"strings"
"google.golang.org/grpc/metadata"
"github.com/andela/micro-api-gateway/pb/authorization"
@daonhan
daonhan / file-uploader.component.html
Created September 1, 2020 04:55 — forked from stuartaccent/file-uploader.component.html
Angular 7 file uploader with queue and progress using HttpClient, example https://stackblitz.com/edit/angular-7-file-upload-queue
<div class="row">
<div class="col-md-3">
<h3>Select files</h3>
<input type="file" #fileInput multiple (change)="addToQueue()" />
</div>
<div class="col-md-9">
<h3>Upload queue</h3>
<table class="table-headed table-striped">