Skip to content

Instantly share code, notes, and snippets.

View chuoique's full-sized avatar

Nguyễn Duy Vượng chuoique

  • Phu Ly - Viet Nam
View GitHub Profile
@chuoique
chuoique / serial.c
Created September 20, 2022 08:43 — forked from DavidEGrayson/serial.c
Simple Windows C program that connects to a serial port and prints out events from it, such as ring signals.
// Lots of code was copied from https://msdn.microsoft.com/en-us/library/ff802693.aspx#serial_topic3
#include <assert.h>
#include <windows.h>
#include <stdio.h>
#include <stdbool.h>
void ReportStatusEvent(HANDLE port, DWORD s)
{
printf("event 0x%lx", s);
@chuoique
chuoique / loadJson.js
Created February 16, 2019 04:23 — forked from pwittchen/loadJson.js
Loading JSON file with JavaScript. Please note: it won't run as a "local" script. JavaScript does not allow to load local files due to security reasons. You should deploy it on the server in order to load JSON file.
function loadJson(callback) {
var XmlHttpRequest = new XMLHttpRequest();
XmlHttpRequest.overrideMimeType("application/json");
XmlHttpRequest.open('GET', 'file.json', true);
XmlHttpRequest.onreadystatechange = function () {
if (XmlHttpRequest.readyState == 4 && XmlHttpRequest.status == "200") {
// .open will NOT return a value
// but simply returns undefined in async mode so use a callback
callback(XmlHttpRequest.responseText);
}