Skip to content

Instantly share code, notes, and snippets.

View vargheseraphy's full-sized avatar

Raphy Varghese vargheseraphy

View GitHub Profile
@vargheseraphy
vargheseraphy / PostgreSQL.md
Created March 16, 2015 06:08
PostgreSQL Administering the Database Create User & Database

##Installation

Install PostgreSQL using apt-get

sudo apt-get install postgresql

For PostgreSQL to work with Ruby, we need the client (application interface) library.

@vargheseraphy
vargheseraphy / git_commands.md
Last active August 29, 2015 14:17
git commands - upstream , remote url, merge branch, console color

Add user name and mail to git repoository

  • git config --global user.name "User Name"
  • git config --global user.email [email protected]

Some commands for the smooth git work flow

git init
  • initialize a git repository
git Log
@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
@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 / 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 / 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?

"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 / 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