Skip to content

Instantly share code, notes, and snippets.

@itsrifat
itsrifat / GenerateMetadataXml.java
Created September 18, 2014 04:44
client code for generating metadata that conforms to ISO 19115 using APache SIS
package edu.unr.nccp;
import org.apache.sis.internal.jaxb.gmi.MI_Metadata;
import org.apache.sis.metadata.iso.citation.DefaultContact;
import org.apache.sis.metadata.iso.citation.DefaultResponsibleParty;
import org.opengis.metadata.Metadata;
import org.opengis.metadata.citation.Contact;
import org.opengis.metadata.identification.CharacterSet;
import org.opengis.metadata.maintenance.ScopeCode;
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<gmi:MI_Metadata xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gts="http://www.isotc211.org/2005/gts" xmlns:gmx="http://www.isotc211.org/2005/gmx" xmlns:gmi="http://www.isotc211.org/2005/gmi" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:srv="http://www.isotc211.org/2005/srv" xmlns:ns9="http://www.w3.org/1999/xlink">
<gmd:language>
<gmd:LanguageCode codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#LanguageCode" codeListValue="eng" codeSpace="eng">English</gmd:LanguageCode>
</gmd:language>
<gmd:characterSet>
<gmd:MD_CharacterSetCode codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#MD_CharacterSetCode" codeListValue="utf8">UTF-8</gmd:MD_CharacterSetCode>
</gmd:characterSet>
<gmd:hierarchyLevel>
<gmd:MD_ScopeCode codeList="h

This is a sample client code that generates a partial xml file using Apache SIS that conforms to ISO 19115 schema:

package edu.unr.nccp;
 
 
import org.apache.sis.internal.jaxb.gmi.MI_Metadata;
import org.apache.sis.metadata.iso.citation.DefaultContact;
import org.apache.sis.metadata.iso.citation.DefaultResponsibleParty;
import org.opengis.metadata.Metadata;
@itsrifat
itsrifat / gap.py
Last active August 29, 2015 14:08 — forked from michiexile/gap.py
A Python implementation of the Gap Statistic from Tibshirani, Walther, Hastie to determine the inherent number of clusters in a dataset with k-means clustering. This fork uses the kmeans implementation of scikit-learn. For some reason scipy.cluster.vq.kmeans2 is not working for my data. I'm getting this error with scipy.cluster.vq.kmeans2 http:/…
# gap.py
# (c) 2013 Mikael Vejdemo-Johansson
# BSD License
#
# SciPy function to compute the gap statistic for evaluating k-means clustering.
# Gap statistic defined in
# Tibshirani, Walther, Hastie:
# Estimating the number of clusters in a data set via the gap statistic
# J. R. Statist. Soc. B (2001) 63, Part 2, pp 411-423
@itsrifat
itsrifat / extract_frames.cpp
Last active July 13, 2023 18:48
simple c++ functions to extract frames of a video file into a vector of Mat and saving the vector as jpg images using OpenCV 2.4.9
/*
This functions opens a video file and extracts the frames and put them into a vector of Mat(its the class for representing an img)
*/
void extract_frames(const string &videoFilePath,vector<Mat>& frames){
try{
//open the video file
VideoCapture cap(videoFilePath); // open the video file
if(!cap.isOpened()) // check if we succeeded
CV_Error(CV_StsError, "Can not open Video file");
@itsrifat
itsrifat / captcha_cracker.py
Last active August 29, 2015 14:11
Solution to the captcha cracker challenge in hackerrank
import numpy as np
from sklearn.linear_model import LogisticRegression
train_x = [
[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,18,0,3,18,0,255,255,0,255,255,255,255,255,255,255,15,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,0,2,0,10,0,255,255,255,2,255,255,255,255,255,255,255,1,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,31,255,255,255,255,255,255,255,0,8,0,0,0,8,255,255],
[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,18,6,0,255,255,10,0,255,255,255,13,13,255,0,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,6,255,255,255,255,255,255,255,0,255,255,255,0,5,0,255,0,255,255,255,255,3,11,255,0,255,255,255,255,0,0,255,0,6,255,255,255,13,0,255,255,0,0,0,8,0,255,255],
[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,12,255,2
@itsrifat
itsrifat / captcha_main.py
Last active August 29, 2015 14:12
captcha cracker challenge in hackerrank
#build a model with your favourite classifier !
from sklearn.linear_model import LogisticRegression
#read the raw training data
data = readData(directory)
#prepare the training data from the raw data
trainingdata = prepareTrainingData(data)
#create the classifier
clf = LogisticRegression()
@itsrifat
itsrifat / template.html
Created March 31, 2015 00:47
Bootstrap Resume Template (using bootstrap 3). Demo available at: http://www.bootsnipp.com/snippets/featured/simple-resume-template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- This file has been downloaded from Bootsnipp.com. Enjoy! -->
<title>Simple Resume template - Bootsnipp.com</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">
<!-- resume specific style -->
<style type="text/css">
@itsrifat
itsrifat / prepare-commit-msg.sh
Created November 16, 2016 09:41 — forked from bartoszmajsak/prepare-commit-msg.sh
How to automatically prepend git commit with a branch name
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"
@itsrifat
itsrifat / install-pre-commit.sh
Created November 16, 2016 17:17 — forked from stefansundin/install-pre-commit.sh
Git pre-commit check to stop accidental commits to master and develop branches. There is also a variant with a core.whitespace check.
#!/bin/sh
# This script will install a Git pre-commit hook that stop accidental commits to master and develop branches.
# There is also a variant that includes a core.whitespace check. See pre-commit-2 below.
# Install in current Git repo:
# curl -fL https://gist.githubusercontent.com/stefansundin/9059706/raw/install-pre-commit.sh | sh
# Install with core.whitespace check:
# curl -fL https://gist.githubusercontent.com/stefansundin/9059706/raw/install-pre-commit.sh | sh -s pre-commit-2
# Install with core.whitespace check and EOF-newline-check:
# curl -fL https://gist.githubusercontent.com/stefansundin/9059706/raw/install-pre-commit.sh | sh -s pre-commit-3
# Install only core.whitespace check: