Skip to content

Instantly share code, notes, and snippets.

View pranny's full-sized avatar

Pranav Prakash pranny

View GitHub Profile
@pranny
pranny / massive_record_migrations.rb
Created September 12, 2016 12:19
massive_record table creations
# A workaround (hackish) way to perform migrations using ORM style models
# and massive_record. Ideally, you shouldn't be using this because
# in massive_record ORM, tables are created (with column families)
# whenever you perform an action toward the database. However if you are unlucky
# and get stuck with issues like
# https://github.com/CompanyBook/massive_record/issues/95#issuecomment-246317908
# this script provides a useful way to deal with it.
require 'activerecord'
@pranny
pranny / ansible_ruby_parser.rb
Created June 29, 2016 07:51
Ruby script to parse ansible host file into hash
# The ansible hosts file parser class
class AnsibleHostsFileParser
HOST_NAME_REGEX = /^\[(.*)\]$/
IP_ADDR_REGEX = /^((?:[0-9]){1,3}\.){1,3}[0-9]{1,3}$/
def self.load_hosts(hostsfile)
f = File.open(hostsfile)
t = f.read
f.close
@pranny
pranny / spree_variants_weight.rb
Created May 4, 2016 06:17
Get variants weight in Spree
# Get all products in Spree
Spree::Product.all
# Get all variants of a single product
prod = Spree::Product.first
prod.variants
# Get the weight of a variant
v = prod.variants.first
v.weight
bool findConcaveHull(pcl::PointCloud <pcl::PointXYZRGB>::Ptr cloud, pcl::PointCloud <pcl::PointXYZRGB>::Ptr &hull)
{
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_projected (new pcl::PointCloud<pcl::PointXYZRGB>);
pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients);
pcl::PointIndices::Ptr inliers (new pcl::PointIndices);
// Create the segmentation object
pcl::SACSegmentation<pcl::PointXYZRGB> seg;
// Optional
@pranny
pranny / openmvg.sh
Last active August 29, 2015 14:19
Shell Script to do Sfm in OpenMVG
#!/bin/sh
# @author Pranav Prakash <pranny@gmail.com>
#
# this script is for easy use of OpenMVG
#
# usage : ./OpenMVG.sh image_dir output_dir
#
# image_dir is the input directory where images are located
# output_dir is where the project must be saved
#