Skip to content

Instantly share code, notes, and snippets.

View sureshmelvinsigera's full-sized avatar

Suresh Melvin Sigera sureshmelvinsigera

View GitHub Profile
@sureshmelvinsigera
sureshmelvinsigera / Gun-related violence.ipynb
Created May 12, 2018 02:18
GUN VIOLENCE DATA ANALYSIS AND VISUALIZATION
@sureshmelvinsigera
sureshmelvinsigera / leetcode-bloomberg.md
Created June 7, 2019 15:47 — forked from jayant91089/leetcode-bloomberg.md
Answers to leetcode questions tagged 'Bloomberg'

121 Best Time to Buy and Sell Stock

Say you have an array for which the ith element is the price of a given stock on day i.

If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit.

Example 1: Input: [7, 1, 5, 3, 6, 4] Output: 5

@sureshmelvinsigera
sureshmelvinsigera / pets.py
Created March 3, 2020 16:18 — forked from jhamrick/pets.py
Demonstration of python classes and inheritance.
class Pet(object):
def __init__(self, name, species):
self.name = name
self.species = species
def getName(self):
return self.name
def getSpecies(self):

Two of the most commonly used data structures in web development are stacks and queues. The history of pages visited in a web browser and the undo operation in a text editor are examples of operations made possible using stacks. The handling of events in web browsers often uses a queue data structure.

Stack

A stack is a data structure that stores elements in a LIFO (Last In First Out) order. It's like a stack of plates in your kitchen. When a plate is added, it is pushed towards the bottom of a stack. The last plate that you stack becomes the one on the top of the stack and it is the first one that you get to use.

A stack has two basic functions:

  • push(): places data onto the top of a stack
  • pop(): removes data from the top of the stack
@sureshmelvinsigera
sureshmelvinsigera / Pointers.md
Created June 6, 2020 13:10 — forked from CoolOppo/Pointers.md
An excellent guide on pointers, converted from HTML to Markdown

[Source][1]

Pointers

In earlier chapters, variables have been explained as locations in the computer's memory which can be accessed by their identifier (their name). This way, the program does not need to care about the physical address of the data in memory; it simply uses the identifier whenever it needs to refer to the variable. For a C++ program, the memory of a computer is like a succession of memory cells, each one byte in size, and each with a unique address. These single-byte memory cells are ordered in a way that allows data representations larger than one byte to occupy memory cells that have consecutive addresses. This way, each cell can be easily located in the memory by means of its unique address. For example, the memory cell with the address 1776 always follows immediately after the cell with address 1775 and precedes the one with 1777, and is exactly one thousand cells after 776 and exactly one thousand cells before 2776. When a variable is declared, the memory needed

@sureshmelvinsigera
sureshmelvinsigera / Mongo.md
Created July 15, 2020 13:42 — forked from jnewman12/Mongo.md
Data Modeling With Mongo

Data Modeling with MongoDB

mongo


Objectives

  • Understand model relationships in MongoDB
  • Understand One-to-Many relationships
@sureshmelvinsigera
sureshmelvinsigera / index.md
Created July 29, 2020 13:28 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@sureshmelvinsigera
sureshmelvinsigera / RAILS_5_CHEATSHEET.md
Created July 29, 2020 13:34 — forked from harrietty/RAILS_5_CHEATSHEET.md
Ruby on Rails 5 Cheatsheet

Ruby on Rails Cheatsheet (5.1)

Architecture

RVM

$ rvm list - show currently installed Rubies

@sureshmelvinsigera
sureshmelvinsigera / ActiveRecord Cheat Sheet v1
Created July 29, 2020 13:45 — forked from jessieay/ActiveRecord Cheat Sheet v1
Active Record cheat sheet with examples of queries I've needed most so far
ActiveRecord cheat sheet / EXAMPLES
INSTALL
=======
$ gem install activerecord
in GEMFILE: gem ‘activerecord’
REQUIRE
=======
require ‘active_record’
@sureshmelvinsigera
sureshmelvinsigera / .Apply() Method
Created October 27, 2020 13:59 — forked from mweisi/.Apply() Method
.Apply() Method
# Define recode_sex()
# Recoding variables is a common data cleaning task. Functions provide a mechanism for you to abstract away complex bits of code as well as # reuse code. This makes your code more readable and less error prone.
# You can use the .apply() method to apply a function across entire rows or columns of DataFrames. However, note that each column of a DataFrame # is a pandas Series. Functions can also be applied across Series. Here, you will apply your function over the 'sex' column.
def recode_sex(sex_value):
# Return 1 if sex_value is 'Male'
if sex_value == 'Male':
return 1