I hereby claim:
- I am manojnaidu619 on github.
- I am manojkumar619 (https://keybase.io/manojkumar619) on keybase.
- I have a public key ASBRwy21N3auADlR8_n5A1M67ydjVsOAc6A56SOF6fKRiQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
class ArticleImageUploader < ImageUploader | |
process :fix_exif_rotation | |
process :strip | |
process :convert => 'jpg' | |
process :quality => 85 # Percentage from 0 - 100 | |
version :gallery_thumb do | |
process :resize_to_fill => Settings.images.article_images.processing.gallery_thumb #44x44 | |
end |
N+1 query problem
eager_load
where
preload
function subset(nums) { | |
var result = []; | |
dfs(0, [], nums, result); | |
console.log(result); | |
} | |
function dfs(index, path, nums, res) { | |
res.push([...path]) | |
for (var i = index; i < nums.length; i += 1){ | |
path.push(nums[i]); |
const gridTraveler = (m, n, memo={}) => { | |
const key = `${m},${n}` | |
if (key in memo) return memo[key] | |
if (m === 1 && n === 1) return 1 | |
if (m === 0 || n === 0) return 0 | |
memo[key] = gridTraveler(m - 1, n, memo) + gridTraveler(m, n - 1, memo) | |
return memo[key] | |
} | |
console.log(2,2) // 2 | |
console.log(gridTraveler(18,18)) //2333606220 |
import pandas, os, random | |
import matplotlib.pyplot as plt | |
from datetime import datetime | |
from alpha_vantage.timeseries import TimeSeries | |
from alpha_vantage.cryptocurrencies import CryptoCurrencies | |
####### Values could be customized (Right now we are choosing random values) ############ | |
CHARTDOMAIN = random.choice(['stock', 'cryptocurrency']) |
###################### | |
# | |
# Monkey patch to ActiveRecord to prevent 'implicit' checkouts. Currently tested with Rails 4.0.8, prob | |
# should work fine in Rails 4.1 too. | |
# | |
# If you create a thread yourself, if it uses ActiveRecord objects without | |
# explicitly checking out a connection, one will still be checked out implicitly. | |
# If it is never checked back in with `ActiveRecord::Base.clear_active_connections!`, | |
# then it will be leaked. | |
# |
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query | |
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails | |
#payload: [{"kind"=>"person"}] | |
Segment.where("payload @> ?", [{kind: "person"}].to_json) | |
#data: {"interest"=>["music", "movies", "programming"]} | |
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json) | |
Segment.where("data #>> '{interest, 1}' = 'movies' ") | |
Segment.where("jsonb_array_length(data->'interest') > 1") |
class Node: | |
def __init__(self, data): | |
self.data = data | |
self.next = None | |
class LinkedList: | |
def __init__(self): | |
self.head = None | |
def form_ll(self, length): |
# Problem here -> https://www.geeksforgeeks.org/find-pythagorean-triplet-in-an-unsorted-array/ | |
nums = [10, 4, 6, 12, 5] | |
found = False | |
for x in range(0, len(nums)): nums[x] *= nums[x] | |
nums.sort() | |
checker = len(nums) - 1 |