Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@itsrifat
itsrifat / import-replacer.tsx
Last active August 31, 2020 05:58
jscodeshift script to replace an import with another. should be called like `find $1 -iname '*.tsx' -print | xargs ./node_modules/.bin/jscodeshift -t import-replacer.ts -fromModule react-apollo -fromImport graphql -toModule @apollo/client -toImport graphql`
/* tslint:disable */
// @ts-nocheck
/*
* This codemod can replace imports
* for exmalple it can change
* import {compose} from 'react-apollo'
* into
* import {flowRight as compose} from 'lodash'
*
Should be called like:
@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:
@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 / 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 / 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 / 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 / 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 / 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

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;