This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lookup_hash | |
h = {} | |
letter = 'a' | |
count = 1 | |
for i in (1..26) | |
h[letter] = count | |
letter = letter.next | |
count += 1 | |
end | |
h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
=end | |
def lookup_hash | |
h = {} | |
letter = 'a' | |
count = 1 | |
for i in (1..26) | |
h[letter] = count |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @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) |
NewerOlder