Skip to content

Instantly share code, notes, and snippets.

View arumoy's full-sized avatar

Arumoy Chakraborty arumoy

View GitHub Profile
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package svm_train;
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/ml.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/core.hpp>
using namespace cv;
const std::string TRAINING_DATA_ROOT = "E:\\SVM_Training\\";
@arumoy
arumoy / OpenOtherAppFromUnityScript.cs
Created December 26, 2016 03:37
Open Other App From Unity C# Script - Android
public void OpenApp() {
string bundleId = "<App Package Name>"; // your target bundle id
AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject ca = up.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject packageManager = ca.Call<AndroidJavaObject>("getPackageManager");
//if the app is installed, no errors. Else, doesn't get past next line
AndroidJavaObject launchIntent = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage",bundleId);
ca.Call("startActivity",launchIntent);
'use strict';
module.exports = function(Agrirouter) {
Agrirouter.closestRouter = function(fieldid, lat, long, cb) {
var response;
Agrirouter.find({"where":{"fieldid":fieldid}},function (err, ret) {
for (var i = 0; i >= ret.length - 1; i++) {
var delPhi = ret[i]["lat"] - lat;
var delLambda = ret[i]["long"] - long;
var R = 6371000;
@arumoy
arumoy / GreatCircleDistance.js
Created December 7, 2016 18:50
Great Circle Distance calculator in JS
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&libraries=geometry"></script>
<script>
var p1 = new google.maps.LatLng(12.851853, 77.664216);
var p2 = new google.maps.LatLng(12.851854, 77.664219);
alert(calcDistance(p1, p2));
//calculates distance between two points in km's
function calcDistance(p1, p2) {
@arumoy
arumoy / GreatCircle.cs
Created December 7, 2016 18:38
Great Circle Haversine function on .NET framework.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GreatCircleNavigation
{
class Program
{
@arumoy
arumoy / screenshotOfJframe.java
Last active February 4, 2016 05:15
Take screenshot of a particular JFrame in Swing(Java)
private void scrshtActionPerformed() {
/**
* this gist outline the process to grab the screenshot of a particular
* JFrame in Swing from which the method is invoked
*
* "this" is the particualr frame here
* */
BufferedImage screenshotImage = new BufferedImage(
this.getBounds().width, this.getBounds().height,
BufferedImage.TYPE_INT_RGB);