Skip to content

Instantly share code, notes, and snippets.

View aashish's full-sized avatar

Aashish Kiran aashish

  • India
View GitHub Profile
Orders table with columns serviceid, Date, name, regionid
Region table with columns id, name
service table with columns id, fees
@aashish
aashish / url_shortener.rb
Created May 16, 2015 13:48
google url shortener
curl https://www.googleapis.com/urlshortener/v1/url?key=AIzaSyBm7qeH-ey9sycnGi1sy8Barqm5f1E_ESU -H 'Content-Type: application/json' -d '{"longUrl": "http://www.google.com/"}'
{
"kind": "urlshortener#url",
@aashish
aashish / game_of_life.rb
Last active August 29, 2015 14:21
The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway. The "game" is a zero-player game, meaning that its evolution is determined by its initial state, requiring no further input. One interacts with the Game of Life by creating an initial configuration and observing how it ev…
class GameOfLife
def initialize(name, size, generations, initial_life=nil)
@size = size
@board = new_board
populate_board(initial_life)
print_board(name, 0)
reason = generations.times do |gen|
prev_board = @board
@board = evolve
@aashish
aashish / combination.rb
Last active August 29, 2015 14:01
Number of possible equations of K numbers whose sum is N
#Input: K, N (where 0 < N < ∞, 0 < K < ∞, and K <= N)
# Number of possible equations of K numbers whose sum is N
#
#Example Input: N=10 K=3
#
#Example Output:
#Total unique equations = 8
#1 + 1 + 8 = 10
#1 + 2 + 7 = 10
#1 + 3 + 6 = 10
class Dictionary
attr_accessor :entries
attr_accessor :keywords
def initialize
@x = Hash.new
end
def entries
@x