Skip to content

Instantly share code, notes, and snippets.

View guinso's full-sized avatar

Benjamin Ching guinso

  • Penang, Malaysia
View GitHub Profile
@guinso
guinso / camera-example.js
Created August 22, 2019 00:54
Example to run camera on web browser
initCamera(videoElement) {
// Grab elements, create settings, etc.
// var video = this.partial.querySelector('#video');
// Get access to the camera!
if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
// Not adding `{ audio: true }` since we only want video now
navigator.mediaDevices.getUserMedia({ video: true }).then(function(stream) {
//video.src = window.URL.createObjectURL(stream);
videoElement.srcObject = stream;
@guinso
guinso / main.go
Created October 9, 2017 02:07
Sample SMTP with attachment
package main
import (
"crypto/tls"
"encoding/base64"
"fmt"
"io/ioutil"
"log"
"net/smtp"
"strings"
@guinso
guinso / main.go
Created October 9, 2017 01:10
Simple SMTP sample
package main
import (
"crypto/tls"
"fmt"
"log"
"net/smtp"
"strings"
)
@guinso
guinso / HttpRequestSample(API 23).java
Last active April 12, 2017 05:52
Sample code demo retrieve HTTP request content for Android Mashmallow
package com.example.guinso.restclientdemo;
import android.os.AsyncTask;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import java.io.ByteArrayOutputStream;
@guinso
guinso / MixedWebHosting.go
Last active March 14, 2021 16:39
Example hosting Golang web server where supporting both static file and dynamic request (REST)
/**
This web server serve 2 different type request: [static file] and [dynamic path]
[Static file] URL path: /*
[Dynamic Path] URL path: /api/*
Preparation:
1) Create "static-files" directory to place all static file like index.html
2) Create "dynamic-files" diectory to place all dynamic or hidden logical files, example invoice.pdf
3) Place "index.html" at root of "static-files" directory
4) Place "neon.jpg" (any kind of JPEG file) at root of "dynamic-files" directory