Skip to content

Instantly share code, notes, and snippets.

View gnsx's full-sized avatar

Kevin D'Souza gnsx

View GitHub Profile
@gnsx
gnsx / DateTime difference Calculator in JS
Last active March 29, 2016 08:35
JS Code to calculate difference between two time-stamps. Reference : http://stackoverflow.com/questions/1787939/check-time-difference-in-javascript
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Leaflet Label</title>
</head>
<body>
<script>
package main
import (
"fmt"
"gocsv"
"os"
"math"
"time"
"strconv"
"encoding/json"
@gnsx
gnsx / ffmpeg_opencv.py
Created July 21, 2017 18:40 — forked from eruffaldi/ffmpeg_opencv.py
Feeding Python Opencv with FFmpeg
#
# Reading video from FFMPEG using subprocess - aka when OpenCV VideoCapture fails
#
# 2017 note: I have realized that this is similar to moviepy ffmpeg reader with the difference that here we support YUV encoding
# BUT we lack: bufsize in POpen and creation flags for windows
# https://github.com/Zulko/moviepy/blob/master/moviepy/video/io/ffmpeg_reader.py
#
# Emanuele Ruffaldi 2016
import cv2
import subprocess
@gnsx
gnsx / go-smtp.go
Last active April 22, 2021 01:55
go-smtp.go
package main
import (
"fmt"
"github.com/go-gomail/gomail"
)
func main () {
fmt.Printf("Hello")
m := gomail.NewMessage()
@gnsx
gnsx / pg.go
Created October 17, 2018 08:17 — forked from itang/pg.go
golang + postgreSQL example
package main
import (
"database/sql"
"fmt"
"log"
// load postgres driver
_ "github.com/lib/pq"
)
@gnsx
gnsx / Unity3D_Android_Sharing_Text.cs
Last active October 30, 2018 08:51
C# script for Unity to share via Android
/*
Credit:
https://medium.com/@agrawalsuneet/native-android-text-sharing-in-unity-app-23f7f8e69978
*/
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class NativeTextShare : MonoBehaviour {
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@gnsx
gnsx / go-sort-map.go
Created February 15, 2019 11:23 — forked from flaviocopes/go-sort-map.go
Go: sort a Map by key #golang
import "sort"
ages := map[string]int{
"a": 1,
"c": 3,
"d": 4,
"b": 2,
}
names := make([]string, 0, len(ages))
//Sort implementation for custom types
// Encapsulates the statistical data that CloudWatch computes from metric data.
type Datapoint struct {
_ struct{} `type:"structure"`
// The average of the metric values that correspond to the data point.
Average *float64 `type:"double"`
// The percentile statistic for the data point.
ExtendedStatistics map[string]*float64 `type:"map"`
package main
import (
b64 "encoding/base64"
"fmt"
"io/ioutil"
"os"
)
func main() {