Skip to content

Instantly share code, notes, and snippets.

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
View deploy.sh
#!/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.
View staging_deploy.sh
#!/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'
View hundred.rb
def lookup_hash
h = {}
letter = 'a'
count = 1
for i in (1..26)
h[letter] = count
letter = letter.next
count += 1
end
h
View points.rb
=begin
=end
def lookup_hash
h = {}
letter = 'a'
count = 1
for i in (1..26)
h[letter] = count
@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
View ruby-upload-s3.rb
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,
View univalue.rb
# Definition for a binary tree node.
# class TreeNode
# attr_accessor :val, :left, :right
# def initialize(val = 0, left = nil, right = nil)
# @val = val
# @left = left
# @right = right
# end
# end
View 1514. Path with Maximum Probability
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
View 2ddp.java
class Solution {
public int change(int amount, int[] coins) {
int[][] dp = new int[coins.length + 1][amount + 1];
dp[0][0] = 1;
for (int j = 1; j <= coins.length; j++) {
dp[j][0] = 1; // number ways of selecting for amount zero is 1
for (int i = 1; i <= amount; i++) {
dp[j][i] = dp[j - 1][i]; // exclude current coin
if (i - coins[j - 1] >= 0) { // check if amount >= to the current i`th coin
dp[j][i] += dp[j][i - coins[j - 1]]; // include current coin
View partition_list.rb
# Definition for singly-linked list. https://leetcode.com/problems/partition-list/submissions/
# class ListNode
# attr_accessor :val, :next
# def initialize(val = 0, _next = nil)
# @val = val
# @next = _next
# end
# end
# @param {ListNode} head
# @param {Integer} x
View count_good_triplets.rb
# @param {Integer[]} arr
# @param {Integer} a
# @param {Integer} b
# @param {Integer} c
# @return {Integer}
def count_good_triplets(arr, a, b, c)
count = 0
size = arr.size
for i in (0..size-3)
for j in (i+1..size-2)