Skip to content

Instantly share code, notes, and snippets.

View arumoy's full-sized avatar

Arumoy Chakraborty arumoy

View GitHub Profile
@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);
@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 / 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) {
'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 / 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);
#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\\";
/*
* 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;
import re
import os
import sys
sa = os.listdir(sys.argv[1])
def show1to5(sl):
for i in range(0, len(sl)):
try:
@arumoy
arumoy / merge-pdf-ghostscript.md
Created August 4, 2018 09:46 — forked from brenopolanski/merge-pdf-ghostscript.md
Merge multiple PDFs using Ghostscript

A simple Ghostscript command to merge two PDFs in a single file is shown below:

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combine.pdf -dBATCH 1.pdf 2.pdf

Install Ghostscript:

Type the command sudo apt-get install ghostscript to download and install the ghostscript package and all of the packages it depends on.

@arumoy
arumoy / clipmod.py
Created September 26, 2018 06:26
pyperclip snippet to mod clipboard text - make script shortcut and invoke
import pyperclip, re
text = pyperclip.paste()
text = re.sub(r"(\{|\})",r"\\\1",text)
pyperclip.copy(text)