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
# lib/tasks/db.rake | |
namespace :db do | |
desc "Dumps the database to db/APP_NAME.dump" | |
task :dump => :environment do | |
cmd = nil | |
with_config do |app, host, db, user| | |
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump" | |
end | |
puts cmd |
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: | |
def generateParenthesis(self, n: int) -> List[str]: | |
result = [] | |
def helper(l, r, temp): | |
if l == r == n: | |
result.append("".join(temp[:])) | |
if l < n: | |
helper(l + 1, r, temp + ["("]) | |
if r < l: | |
helper(l, r + 1, temp + [")"]) |
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: | |
def subsetsWithDup(self, nums: List[int]) -> List[List[int]]: | |
result = [] | |
nums.sort() | |
def helper(idx, temp): | |
result.append(temp[:]) | |
for i in range(idx, len(nums)): | |
if i > idx and nums[i] == nums[i-1]: | |
continue | |
temp.append(nums[i]) |
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: | |
def subsets(self, nums: List[int]) -> List[List[int]]: | |
result = [] | |
temp = [] | |
def helper(idx): | |
if idx > len(nums): | |
return | |
result.append(temp[:]) | |
for i in range(idx, len(nums)): |
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: | |
def combinationSum3(self, k: int, n: int) -> List[List[int]]: | |
result = [] | |
def helper(idx): | |
if len(temp) == k and sum(temp) == n: | |
result.append(temp[:]) | |
if sum(temp) > n or len(temp) > k: | |
return | |
for i in range(idx, 10): |
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: | |
def combinationSum2(self, nums: List[int], target: int) -> List[List[int]]: | |
nums.sort() | |
result = [] | |
def helper(idx, temp, cur): | |
if cur == target : | |
result.append(temp[:]) | |
if cur > target: | |
return | |
for i in range(idx, len(nums)): |
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: | |
def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]: | |
result = [] | |
def helper(idx, temp, cur): | |
if cur == target: | |
result.append(temp[:]) | |
return | |
if cur > target: | |
return |
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
# temp + [i] creates a new array pointer that is why we do a copy. deep copy creates new instance of element inside the array. here copy is enough. | |
class Solution: | |
def combine(self, n: int, k: int) -> List[List[int]]: | |
def dfs(idx, temp): | |
if len(temp) == k: | |
result.append(temp[:]) | |
# return | |
for i in range(idx, n + 1): | |
temp.append(i) |
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
int icon = 0;// = R.drawable.ic_stat_gcm; | |
long when = System.currentTimeMillis(); | |
NotificationManager notificationManager = (NotificationManager) | |
context.getSystemService(Context.NOTIFICATION_SERVICE); | |
Notification notification = new Notification(R.drawable.icon, "You have a new "+app, when); | |
notification.vibrate = new long[] { 100, 250, 100, 500}; | |
String title = context.getString(R.string.app_name); | |
Intent notificationIntent = null; | |
// notificationIntent = new Intent(context, HomeScreen.class) ; |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
NewerOlder