Skip to content

Instantly share code, notes, and snippets.

View bparanj's full-sized avatar

Bala Paranj bparanj

View GitHub Profile
@bparanj
bparanj / deploy.sh
Created June 8, 2022 17:41 — forked from danchoi/deploy.sh
Simple Rails deploy bash script
#!/bin/bash
# deploy.sh
# Put this script on your production server and make it executable with chmod
# +x.
# Set the deploy_dir variable to the path on the production server to
# deployment directory. The script assumes the deployment directory is a git
# clone of the codebase from an upstream git repo. This script also assumes
@bparanj
bparanj / staging_deploy.sh
Created June 8, 2022 17:41 — forked from sstarr/staging_deploy.sh
A sample Bash deployment script. This is for a Rails app hosted on an OS X server.
#!/usr/bin/env bash
# Configuration
SERVER='10.20.30.40'
DEPLOY_TO='/Users/simon/apps/some_app/staging/'
EXCLUDE='*.sqlite3 *.swp .DS_Store .git/ tmp/ log/ public/uploads/ uploads/'
DRY_RUN=false
DEPLOY_GEM_PATH='/Users/simon/.rvm/gems/ruby-1.9.2-p180'
MYSQL2_BUNDLE='/Users/simon/apps/some_app/staging/vendor/bundle/ruby/1.9.1/gems/mysql2-0.2.13/lib/mysql2/mysql2.bundle'
@bparanj
bparanj / ruby-upload-s3.rb
Created January 15, 2021 00:07 — forked from db42/ruby-upload-s3.rb
Ruby script to upload a file to amazon s3
require 'aws-sdk-s3' # v2: require 'aws-sdk'
ACCESS_KEY_ID = ""
SECRET_ACCESS_KEY = ""
REGION_ID = "us-east-1"
BUCKET_NAME = "bucket-name"
def uploadS3
credentials = Aws::Credentials.new(
ACCESS_KEY_ID,
from collections import defaultdict
import heapq
class Solution:
def maxProbability(self, n: int, edges: List[List[int]], succProb: List[float], start: int, end: int) -> float:
'''
Input
n - number of nodes
edges - (u,v) for an undirected edge.
succProb - edge[i]'s weight
start - start node
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode':
'''
class Solution(object):
def insert(self, intervals, newInterval):
"""
:type intervals: List[List[int]]
:type newInterval: List[int]
:rtype: List[List[int]]
"""
'''
Test cases
i) [], [2,5] => [[2,5]]
# 1004: Max ConsecutiveOnes III
maxLength = 0
numZeros = 0
# 1052: Grumpy Bookstore Owner
maxCustWhenGrumpy = 0
idxOfStartX = 0
custWhenGrumpy = 0
# 1456: Max Number of Vowels in Substring of given length
Interval Operations
There are a few operations that can be performed on intervals:
1. Merge interval[] s.t. the all intervals are disjoint.
[0,5],[5,7] ==> [0,7]
2. Insert interval into interval[] s.t. all intervals are disjoint.
3. Find intersection between two interval[].
[0,5],[5,7] => [5,5]
In order to perform these operations, it is important to understand the 6
@bparanj
bparanj / gist:42c9848fa8ae02be0c05d0e7978f9f82
Created January 8, 2019 06:18 — forked from Miserlou/gist:11500b2345d3fe850c92
1000 Largest US Cities By Population
Largest 1000 Cities in America
2013 popuation data - Biggest US Cities By Population
rank,city,state,population,2000-2013 growth
1,New York,New York,8405837,4.8%
2,Los Angeles,California,3884307,4.8%
3,Chicago,Illinois,2718782,-6.1%
4,Houston,Texas,2195914,11.0%
5,Philadelphia,Pennsylvania,1553165,2.6%
@bparanj
bparanj / config.yml
Created November 17, 2018 15:38 — forked from henrypoydar/config.yml
Rails 5.1 CircleCI 2.0 Configuration
version: 2
jobs:
build:
environment:
working_directory: ~/circleci-myapp
docker:
- image: circleci/ruby:2.4.2-node-browsers
environment:
CC_TEST_REPORTER_ID: XXXYYY
RAILS_ENV: test