Skip to content

Instantly share code, notes, and snippets.

Avatar

Parag K Mital pkmital

View GitHub Profile
View gist:77d8c768d9cf66cef7c0
# Example using Decision Trees
import numpy as np
import matplotlib.pylab as plt
%matplotlib inline
all_data = []
with open("data.txt") as input_file:
for line in input_file:
all_data.append([item.replace('\r\n', '') for item in line.split('\t')[1:]])
X = np.vstack(all_data[1:11]).astype(float).transpose() # inputs
@pkmital
pkmital / gist:8a15555d3b29eabaa606
Created May 15, 2015
draw error ellipse from covariance matrix
View gist:8a15555d3b29eabaa606
//from http://www.visiondummy.com/wp-content/uploads/2014/04/error_ellipse.cpp
#include <iostream>
#include <cmath>
//You need OpenCV for this demo
#include <opencv2\core\core.hpp>
#include <opencv2\highgui\highgui.hpp>
cv::RotatedRect getErrorEllipse(double chisquare_val, cv::Point2f mean, cv::Mat covmat);
@pkmital
pkmital / gist:cb828230210e685d628f
Created Apr 24, 2015
YouTube Smash Up - Download Script
View gist:cb828230210e685d628f
#!/bin/bash
youtube-dl --playlist-end 10 -o '%(playlist_index)s.%(ext)s' https://www.youtube.com/channel/UCF0pVplsI8R5kcAqgtoRqoA/videos?view=10&flow=list&live_view=10
for i in `ls *.mp4`; do `ffmpeg -i $i -vn -y "$i".wav`; done
youtube-dl -J --playlist-end 10 https://www.youtube.com/channel/UCF0pVplsI8R5kcAqgtoRqoA/videos?view=10 | json_reformat > titles.json
#output=$(youtube-dl -J --playlist-end 10 https://www.youtube.com/channel/UCF0pVplsI8R5kcAqgtoRqoA/videos?view=10 <&3)
#echo $output > titles.json
View gist:c1aa20cc2b8a1f38f8d1

This is my implementation of tanh for CUDA:


#include <iostream>
#include <math.h>
#include <cuComplex.h>
#include <complex>

typedef double     rtype;
@pkmital
pkmital / notebook-css
Last active Aug 29, 2015
ipython-notebook-css
View notebook-css
<style>
html {
font-size: 62.5% !important; }
body {
font-size: 1.5em !important; /* currently ems cause chrome bug misinterpreting rems on body element */
line-height: 1.6 !important;
font-weight: 400 !important;
font-family: "Raleway", "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif !important;
color: #222 !important; }
View gist:a82ae18c117f3e6e1974
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install libvorbis --universal libsndfile --universal libogg --universal flac --universal
curl -O http://code.soundsoftware.ac.uk/attachments/download/690/vamp-plugin-sdk-2.5.tar.gz
tar -xvf vamp-plugin-sdk-2.5.tar.gz
cd vamp-plugin-sdk-2.5
make -f build/Makefile.osx
@pkmital
pkmital / asyncreadback.cpp
Created Aug 16, 2012
asynchronous readback
View asyncreadback.cpp
void setup()
{
pboIds = new GLuint[2];
pboIds[0] = 0; pboIds[1] = 0;
const int DATA_SIZE = screenWidth * screenHeight * 4;
const int PBO_COUNT = 2;
glGenBuffersARB(PBO_COUNT, pboIds);
glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[0]);
glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, DATA_SIZE, 0, GL_STREAM_READ_ARB);
@pkmital
pkmital / stlVectorTest
Created Aug 25, 2011
seeing if stl vector really keeps data contiguous
View stlVectorTest
#include <vector>
#include <iostream>
using namespace std;
typedef float T;
int main()
{
int data_size = 512;
vector<T *> data;