Skip to content

Instantly share code, notes, and snippets.

View v0dro's full-sized avatar

Sameer Deshmukh v0dro

View GitHub Profile
@v0dro
v0dro / interp2d_octave.mat
Created June 10, 2016 19:10
Octave program for 2D interpolation.
%% saddle: saddle
function [z] = saddle(x, y)
z = x*x - y*y;
endfunction
x = [-20.0,-19.0,-18.0,-17.0,-16.0,-15.0,-14.0,-13.0,-12.0,-11.0,-10.0,-9.0,-8.0,-7.0,-6.0,-5.0,-4.0,-3.0,-2.0,-1.0,0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0];
y = [-20.0,-19.0,-18.0,-17.0,-16.0,-15.0,-14.0,-13.0,-12.0,-11.0,-10.0,-9.0,-8.0,-7.0,-6.0,-5.0,-4.0,-3.0,-2.0,-1.0,0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0];
temp = [];
@v0dro
v0dro / 2dinterp_gsl.rb
Created June 11, 2016 08:07
2D interpolation with rb-gsl in ruby
xarr = GSL::Vector.alloc([-2.0, -1.0, 0.0, 1.0, 2.0])
yarr = GSL::Vector.alloc([-2.0, -1.0, 0.0, 1.0, 2.0])
a = []
xarr.each do |x|
yarr.each do |y|
a << x*x - y*y
end
end
puts a.inspect # this array has been put into the C program
zarr = GSL::Vector.alloc(a)
@v0dro
v0dro / ruby_tensorflow.md
Created May 17, 2016 10:30
Proposal template for tensor flow project

Contact details

Please tell us your contact details like full name, email, github ID, blog, etc.

About Me

What are you currently engaged in? Where do you work or study?

What is your experience level with Ruby? What is your experience with Tensor Flow or AI in general?

@v0dro
v0dro / gpa.rb
Last active September 1, 2016 08:13
college admission prediction example
require 'daru'
require 'statsample-glm'
require 'open-uri'
content = open('http://www.ats.ucla.edu/stat/data/binary.csv')
File.write('binary.csv', content.read)
df = Daru::DataFrame.from_csv "binary.csv"
df.vectors = Daru::Index.new(['admit', 'gre', 'gpa', 'rank'])
df.to_category 'rank'
@v0dro
v0dro / rubex_method.c
Created November 27, 2016 12:41
Code generated by Rubex.
/* C extension for basic_ruby_method.
This file in generated by Rubex. Do not change!
*/
#include <ruby.h>
#include <stdint.h>
VALUE __rubex_f_addition (int argc, VALUE* argv, VALUE __rubex_arg_self);
VALUE __rubex_f_addition (int argc, VALUE* argv, VALUE __rubex_arg_self)
{
int32_t __rubex_arg_a;
@v0dro
v0dro / rag2016.md
Last active January 7, 2017 07:00
RAG rubex proposal
@v0dro
v0dro / weekly_report1.md
Created January 8, 2017 16:09
First RAG 2016 report

Dear Koichi,

I have bunch of questions about Ruby's Garbage Collection. But before I proceed to ask, I would like to update you properly on the current progress that I have accomplished with Rubex.

Previous objectives

As of now I have finished most of the objectives that I had stated in the original proposal that was sent to the Ruby Association. So now, one can declare simple primitive data types, arrays, Ruby methods and even loops in Rubex and all of it is handled gracefully by the Rubex compiler.

@v0dro
v0dro / weekly_report2.md
Last active February 5, 2017 18:55
Second week report

Next week's work

All the objectives that I had specified for the Ruby Grant application final term report except the creating unions and enums have been met.

Rubex can now use code from external C libraries.

For example, to use the RSTRING_LEN macro from the ruby.hheader file in a method, the following code snippet can be used:

lib ruby do
  double RSTRING_LEN(object)
@v0dro
v0dro / daru_ruby_kaigi.md
Created March 28, 2017 17:22
Daru Ruby Kaigi 2016

abstract

Easy and fast analysis of data is an uphill task for any Rubyist today. Ruby has been mostly restricted to web development and scripting, until now. In this talk we will have a look at daru, a gem from the Ruby Science Foundation specifically developed for simplifying data analysis tasks for Rubyists.

You will learn how you can use daru for analyzing large data sets and get a tour of daru being coupled with other Ruby tools like pry, iruby and nyaplot for interactive and standalone data analysis and plotting for gaining quick insights into your data — all with a few lines of Ruby code.

details

This will be an example-driven talk on performing advanced yet simple to understand data analysis tasks in Ruby using daru and other allied scientific gems like iruby, nyaplot, gnuplotrb and nmatrix. Since Ruby is m

# In a calling Ruby script caller.rb
require ‘compiled_binary.so’
def compute_without_gil
t = []
4.times { t << Thread.new { _some_computation }
4.times { t.join }
end