Skip to content

Instantly share code, notes, and snippets.

@karthikselva
karthikselva / dsu.rb
Created April 30, 2017 15:15 — forked from D-side/dsu.rb
Primitive Ruby Disjoint-Set
class DSU
def initialize(x)
@array = Array.new(x) {|i| i }
end
def find(x)
return x if @array[x] == x
@array[x] = find(@array[x])
end
@karthikselva
karthikselva / grep_surround.md
Created August 11, 2016 23:29
Grep bunch of lines surrounding the hit

For BSD or GNU grep you can use -B num to set how many lines before the match and -A num for the number of lines after the match.

grep -B 3 -A 2 foo README.txt

If you want the same number of lines before and after you can use -C num.

grep -C 3 foo README.txt

This will show 3 lines before and 3 lines after.

@karthikselva
karthikselva / Connecting to MySQL using MySQL Workbench.md
Last active August 9, 2016 21:35
Connecting to MySQL using MySQL Workbench

Mysql Inside Vagrant:

sudo nano /etc/mysql/my.cnf change: bind-address = 0.0.0.0
sudo /etc/init.d/mysql restart

Mysql WorkBench:

@karthikselva
karthikselva / spreadsheet_test
Created March 3, 2016 10:47 — forked from phollyer/spreadsheet_test
Spreadsheet Gem - updating an existing sheet without changing the output location or filename
#!/usr/bin/env ruby
require 'spreadsheet'
# Begin Test
print "Spreadsheet Test\n"
# Create the rows to be inserted
row_1 = ['A1', 'B1']
row_2 = ['A2', 'B2']
@karthikselva
karthikselva / octopress_to_jekyll.rb
Last active February 27, 2016 07:56
Octopress to Jekyll Code tag converter
src = /{% include_code\s+([A-Za-z0-9\._]+)\s+%}/
files = Dir['_posts/*']
files.each do |e|
content =nil
File.open(e) do |f|
content = f.read
end
var MyObject = ( function () {
var myPrivate1,myPrivate2;
var myPublicParts = {
public1: function () {
console.log(myPrivate1);
},
public2: function () {
@karthikselva
karthikselva / resume-generator
Last active December 16, 2016 07:00
resume-generator
var markdownpdf = require("markdown-pdf"), fs = require("fs"); fs.createReadStream("resume.md").pipe(markdownpdf()).pipe(fs.createWriteStream("resume_md.pdf"));
@karthikselva
karthikselva / resume
Last active March 22, 2023 14:16
Karthik selvakumar Bhuvaneswaran - Resume
KARTHIK SELVAKUMAR BHUVANESWARAN
--------------------------------
karthikselvakumar7@gmail.com • +91.9080418428 • [https://www.linkedin.com/in/karthikselva/](https://www.linkedin.com/in/karthikselva/)
## Education
### Stanford University - Stanford, California - (Feb 2018 – June 2019)
- **Course:** Artificial Intelligence Graduate Certificate with 3.7/4.0 GPA
- **Specialization:** Deep Learning, Reinforcement Learning
@karthikselva
karthikselva / map_and_symbols
Created March 14, 2013 11:42
I feel geekish ( readability is absent for sure ) when I use map with an symbol proc for an array :D
# Convert all elements in an array from integer to string
[1,2,3].map(&:to_s)
# Test output:
# ===========
#
# 1.8.7-p358 :001 > a = [1,2,3]
#
@karthikselva
karthikselva / relative_numbers_vim
Created March 14, 2013 11:37
To activate relative numbering in VIM use this script. More info on relative numbers here: http://jeffkreeftmeijer.com/2012/relative-line-numbers-in-vim-for-super-fast-movement/
" relative line numbering
" autocmd InsertEnter * :set number
" autocmd InsertLeave * :set relativenumber
function! NumberToggle()
if(&relativenumber == 1)
set number
else
set relativenumber
endif