Skip to content

Instantly share code, notes, and snippets.

View alexcpn's full-sized avatar

Alex Punnen alexcpn

View GitHub Profile
@alexcpn
alexcpn / view.jsp
Created July 30, 2012 13:33
Alloy UI (YUI), Graphics - Draggable Circle , Ajax, Portlet
<!-- http://jsbin.com/utucah/1 In free form -->
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui"%>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet"%>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme"%>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>
<%@ taglib uri="http://liferay.com/tld/util" prefix="liferay-util"%>
@alexcpn
alexcpn / MessageSenderServlet.java
Last active August 29, 2015 14:01
Minimal POM for JBOSS AS7.0 -MDB and a message producer
package com.nokia.oss;
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@alexcpn
alexcpn / histogramparser.py
Created June 24, 2015 06:11
Here is a script to compare two jmap class histogram dumps, to see which classes are increasing memory. This can be used as a rough tool in checking suspect classes while analyzing Java memory leaks, as dumping large heaps and analyzing the same can be hard
__author__ = 'acp'
import re
import fileinput
import operator
import sys
objectschanged={}
def create_object_list(line2,mapofObjects,instance):
@alexcpn
alexcpn / generate_random_point.py
Created November 27, 2015 10:30
Creating a random point at an approximate distance from a given latitude and longitude
# Testing simlation of generating random points
from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import host_subplot
import mpl_toolkits.axisartist as AA
def create_random_point(x0,y0,distance):
"""
Utility method for simulation of the points
from __future__ import division
import numpy as np
RADIUS_OF_EARTH_IN_KM = 6371.01
def haversine(lat1, lon1, lat2, lon2):
"""
Utility to calcutlate distance between two pointtodo explain regarding height
coverting from geodisc co-ordinate to cartestian gives errors when distances are further apart
@alexcpn
alexcpn / gevent_based_queue.py
Created January 20, 2016 08:47
A gevent,greenlet based simple TaskQueue
# Gevent Queue
from gevent import queue
import gevent
from enum import Enum
import time
import threading
class EventId(Enum):
event_added = 1
@alexcpn
alexcpn / override_eq.py
Created February 29, 2016 05:13
Python Proper way to override equal to and hash
# http://stackoverflow.com/questions/390250/elegant-ways-to-support-equivalence-equality-in-python-classes
# http://stackoverflow.com/questions/4352244/python-implementing-ne-operator-based-on-eq/30676267#30676267
class Test1(object):
"""
Proper way to override equality
"""
def __init__(self, str1, str2, num1):
self.str1 = str1
@alexcpn
alexcpn / kdtree.py
Last active June 30, 2021 17:27
Creating a KD tree and algorithm for finding nearest neighbour
from collections import namedtuple
from operator import itemgetter
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import host_subplot
fig =plt.figure(figsize=(10, 8), dpi=80)
ax = plt.gca()
def parse_tree(node,prev_node=None,label='Root'):
# Helper utility to display the KD tree graphically to understand the spatial split
@alexcpn
alexcpn / BootUp.scala
Created August 29, 2016 11:46
Scala Remote Actor Communicaiton
package run
import java.io.File
import akka.actor.{Actor, ActorRef, ActorSelection, ActorSystem, Props}
import com.typesafe.config.ConfigFactory
import org.slf4j.LoggerFactory
/**
* Created by acp on 25-08-2016.
@alexcpn
alexcpn / VideoTestHaar.cpp
Last active June 14, 2022 15:03
opencv Object detection with CUDA
#include "stdafx.h"
#include <iostream>
#include <time.h>
#include "opencv2/objdetect.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/cudaobjdetect.hpp"
#include "opencv2/cudaimgproc.hpp"
#include "opencv2/cudawarping.hpp"