Skip to content

Instantly share code, notes, and snippets.

View vargheseraphy's full-sized avatar
🎯
Focusing

Raphy Varghese vargheseraphy

🎯
Focusing
View GitHub Profile
@vargheseraphy
vargheseraphy / youtube_download.md
Last active August 29, 2015 14:15
download youtube videos from terminal in linux

Install you tube Downloader from linux terminal

sudo apt-get install youtube-dl youtube-dl

youtube-dl -cit http.....(paste the link) youtube-dl http://www.youtube.com/watch?v=_z-hEyVQDRA

You can also specify other options

@vargheseraphy
vargheseraphy / regex_rm_newline.rb
Last active August 29, 2015 14:15
replace new line from matching word
irb1(main):029:0> "- dredtrnedtdj - uifsdkghdkjghjh ".split(/- /)
=> ["", "dredtrnedtdj ", "uifsdkghdkjghjh "]
irb1(main):031:0> "- dredtrnedtdj - fsjfsgdgdgdffff-gdfjdgjdgdg".split(/- /).compact.reject(&:empty?).each {|t| puts "#{t}"}
dredtrnedtdj
fsjfsgdgdgdffff-gdfjdgjdgdg
=> ["dredtrnedtdj ", "uifsdkghdkjghjh ", "fsjfsgdgdgdffff-gdfjdgjdgdg"]
irb1(main):032:0> "- dredtrnedtdj - fsjfsgdgdgdffff - gdfjdgjdgdg".split(/- /).compact.reject(&:empty?).each {|t| puts "#{t}"}
dredtrnedtdj
@vargheseraphy
vargheseraphy / ruby_on_rails.rb
Created February 18, 2015 04:01
Learn rails and its operations , and rails migration
http://www.tutorialspoint.com/ruby-on-rails/rails-migrations.htm
http://railsguides.net/change-data-in-migrations-like-a-boss/
http://makandracards.com/makandra/15575-how-to-write-complex-migrations-in-rails
@vargheseraphy
vargheseraphy / rails.rb
Created February 18, 2015 05:00
migration script to update values in column in a table
class ChangeValueTable_nameColumn_name < ActiveRecord::Migration
def up
db.update("UPDATE table_name SET column_name = 'new_value' WHERE party = 'old_value' ")
end
def down
# action to be done after completing the up ,
# may be deleting the column after completing the values
end
"hello".gsub(/[aeiou]/, '*') #=> "h*ll*"
"hello".gsub(/([aeiou])/, '<\1>') #=> "h<e>ll<o>"
"hello".gsub(/./) {|s| s.ord.to_s + ' '} #=> "104 101 108 108 111 "
"hello".gsub(/(?<foo>[aeiou])/, '{\k<foo>}') #=> "h{e}ll{o}"
'hello'.gsub(/[eo]/, 'e' => 3, 'o' => '*') #=> "h3ll*"
@vargheseraphy
vargheseraphy / machine_learning.md
Last active August 29, 2015 14:16
machine learning and artificial inteligence

6. Learning to Classify Text

Detecting patterns is a central part of Natural Language Processing. Words ending in -ed tend to be past tense verbs (5.). Frequent use of will is indicative of news text (3). These observable patterns — word structure and word frequency — happen to correlate with particular aspects of meaning, such as tense and topic. But how did we know where to start looking, which aspects of form to associate with which aspects of meaning?

The goal of this chapter is to answer the following questions:

How can we identify particular features of language data that are salient for classifying it? How can we construct models of language that can be used to perform language processing tasks automatically? What can we learn about language from these models?

@vargheseraphy
vargheseraphy / scraper.rb
Created March 5, 2015 11:48
Ruby web scraping using mechanize and nokogiri gems
# http://www.icicletech.com/blog/web-scraping-with-ruby-using-mechanize-and-nokogiri-gems
require "mechanize"
url = ARGV[0]
fp = File.new("wikilinks.txt", "w")
agent = Mechanize.new { |agent| agent.user_agent_alias = "Mac Safari" }
html = agent.get(url).body
@vargheseraphy
vargheseraphy / Negotiation.md
Created March 7, 2015 05:49
Negotiation tactics

​Negotiation Tactic #1 – Is That Your Best Offer?

Negotiation Tactic #2 – Referencing an Expert Opinion

Negotiation Tactic #3 – Asking a Closed-Ended Question

Negotiation Tactic #4 – Asking an Open-Ended Question

Negotiation Tactic #5 – Concede Small

@vargheseraphy
vargheseraphy / formatdate.rb
Created March 13, 2015 05:51
Change the date format in ruby using Date.parse
require 'date'
Date.parse("November 17, 2014").strftime('%Y-%m-%d')
#=>"2014-11-17"
Date.parse("November 17, 2014").strftime('%y/%m/%d')
#=>"14/11/17"
# change the '-', '/' or use any separators