Ozodbek | LeetCodin
29 subscribers
14 photos
5 videos
81 links
Download Telegram
Forwarded from Hitchhiking Inverse Log
My job from a year ago has changed and two aspects of the change are hard on me. I think the concern is generalizable.

1. The state of flow is gone. The manual process of writing code used to be my main source of dopamine, for two decades. 99% of the time I was in the state of flow in my life was from coding (the other 1% being piano), and I didn't have it since December. This has impacted my mental health. I had similar symptoms when I left my job at Google to join Amazon as a Principal Engineer (PE) - the job has changed from mostly coding to mostly reviewing design decision and sitting in meetings. That was 5y ago and I've had the same feeling since February.

2. Massive context switching. In the past I'd work on the same thing for long stretches of time without context switching. Now most deep work is done by claudes and I review higher-level decisions, very similar to how a PE often spends all day in 30min meetings, but it's much worse now because I spend maybe 1-5min per discussion iteration per claude, so now I have to context-switch every 1-5min. The job has changed from working on the same thing for hours to a firehouse of unrelated information. This is pretty destructive for my ADHD brain. It took months to realize this side effect.

My brain got hyper-optimized to a specific job for years, but now its priors/habits are suboptimal for the new job. This is not a fun side effect of progress and job transformation.

I don't see any signs suggesting that the progress will slow down, so I suspect the job will transform again in a year. I expect a state of constant change, with accelerated pace. As I wrote before, the moat for an individual like you or me, becomes adaptability. I think the most adaptable fraction of the overall population is kids and young adults. The rate "oh, this is new to me" is highest in the childhood and goes down with age, and so does the need for adaptation, so it atrophies. If you are a student reading this, then somewhat paradoxically, I think you are in the best position, better than professionals with an asset baggage of experience whose value is dropping at an exponential pace.

Don't get used to anything in particular. Stay mentally flexible, keep an open mind. Keep a few things constant for your sanity - in my case it is family, and in particular your shared dna is truly immutable.

Accept that the horizon at which you are able to make accurate predictions about the future will keep shrinking, so don't waste your time on worry/anxiety about the future - your predictions will mostly likely turn out to be wrong and your worry about a particular version of the future you might have imagined will likely to end up being a waste of time and nerves. It's far more optimal focus on the present moment.
👎1
https://leetcode.com/problems/sort-an-array/

Merge sort

class Solution:
def sortArray(self, nums: List[int]) -> List[int]:
temp = [0]*len(nums)

def merge(l, m, r):
i, j = l, m + 1
p = 0
while i <= m and j <= r:
if nums[i] <= nums[j]:
temp[p] = nums[i]
i += 1
else:
temp[p] = nums[j]
j += 1
p += 1
while i <= m:
temp[p] = nums[i]
i += 1
p += 1
while j <= r:
temp[p] = nums[j]
j += 1
p += 1
nums[l: r+1] = temp[: p]


def merge_sort(l, r):
if l < r:
m = (l + r) // 2
merge_sort(l, m)
merge_sort(m + 1, r)
merge(l, m, r)


merge_sort(0, len(nums) - 1)
return nums

# N = nums.length
# Time : O(N Log N)
# Space: O(N)


Counting sort

class Solution:
def sortArray(self, nums: List[int]) -> List[int]:
def counting_sort():
minVal, maxVal = min(nums), max(nums)
count = [0]*(maxVal - minVal + 1)

for num in nums:
count[num - minVal] += 1

index = 0
for val in range(minVal, maxVal + 1):
while count[val - minVal] > 0:
nums[index] = val
index += 1
count[val - minVal] -= 1

counting_sort()
return nums

# K = maxVal − minVal + 1
# N = nums.length
# Time : O(N + K)
# Space: O(K)
👍1
Forwarded from ntx
i don't think there is a particular course that would train this, but a student might be able to do it on their own by putting themselves into unknown/unexpected situations, preferably challenging ones, and try to figure it out on the spot. This would train getting used to uncomfortable situations and improvising.
👎1
Forwarded from Azim Pulat
Algoritmlar boshqaryapti.

Nima iste’mol qilishimizni.
Nima o’ylab, xolashimizni.

Kontent quruvchi sifatida oxirgi yilda “algortim”dagi o’zgarish meni havotirga solyapti.

Yillar davomidagi o’zgarish:
… → social network → social media → media → boshqaruv.

Internetnetda istalgan inson istaganini gapiradi, ammo sizga faqat algoritm istagani eshittiriladi.

Algoritmlarni qayta qurishimiz kerak.
Uzbekonomics
Çorşanba.
Hech qachon ishlatmayman
👍2
Forwarded from Sploitus Agency
Dam olish kuni shunchaki film ko'rish uchun bir saytga kirasan. Qarasang, filmning ba'zi qismlari hali chiqmagan. Yetmaganiga keyingi qismi chiqishi uchun yana 10 kun kutish kerak.

Yo'q, bunaqasi ketmaydi. 😄

Shunchaki Developer Tools ochasan, JavaScript fayllarini titkilay boshlaysan. Qarabsanki, customer va staff uchun ajratilgan bir nechta endpointlar bor ekan.


GET /v1/customer?lang=uz
GET /v1/videos?lang=uz&limit=1
GET /v1/videos/{id}


"Bo'ldi, topdim."

Request yuborasan.

401.

Yana boshqasini yuborasan.

401.

Subdomainlarni topasan. Balki admin API alohidadir deb o'ylaysan.

Yana request.

401.

Nega?

Sababi oddiy. Endpoint Authorization kutyapti, sendagi JWT esa bu endpointlarga kirish huquqiga ega emas.

Xo'sh, endi nima qilamiz?

Albatta yana JavaScript'ga qaytamiz. 😄

Kodlarni o'qib o'tirsam, bir joy e'tiborimni tortdi. Header required, lekin tokenning o'zi haqida deyarli hech qanday tekshiruv yo'q.

Shunchaki sinab ko'rdim.


Authorization: garbage.invalid.token


...va API javob bera boshladi.

/v1/customer

➡️ Ma'lumot qaytdi.

/v1/videos

➡️ Ma'lumot qaytdi.

Lekin eng qiziq joyi hali oldinda ekan.


GET /v1/videos/{id}


Response:


HTTP/1.1 401 Unauthorized


"Demak bo'lmadi."

Lekin response body'ni pastga scroll qilsam...


HTTP/1.1 401 Unauthorized

{"Error":"UNAUTHORIZED"}
{...protected response...}


😂😂

Serverning o'zi "Unauthorized" deyapti, keyingi qatorda esa himoyalangan ma'lumotni berib yuboryapti.

Lekin hikoya shu bilan tugamadi.

Response ichida HLS (`.m3u8`) stream URL ham bor edi.

Yuklab olmoqchi bo'lsam:


yt-dlp "https://stream.example.com/.../playlist.m3u8?token=REDACTED"


Access denied.

Biroz kovlasam, stream IP bo'yicha himoyalangan ekan.

Lekin IP'ni server X-Real-IP headeridan olayotganini ko'rdim.

Shundan keyin shunchaki:


yt-dlp \
--add-header "X-Real-IP: 10.0.1.2" \
--add-header "User-Agent: Mozilla/5.0 (...)" \
--add-header "Referer: https://example.com/" \
--add-header "Origin: https://example.com" \
"https://stream.example.com/.../playlist.m3u8?token=REDACTED" \
-o "movie.%(ext)s"


...va video bemalol yuklandi. 🙂

Xullas, dam olish kuni shunchaki film ko'rmoqchi edim.

Oxiri:

* Authorization bypass topildi.
* 401 Unauthorized qaytarsa ham protected response qaytayotgani aniqlandi.
* Stream URL'lari oshkor bo'layotgani topildi.
* IP-based himoya X-Real-IP headeriga ishonilgani sababli bypass qilindi.

Ba'zida eng qiziqarli bug'lar murakkab exploitlarda emas, oddiy JavaScript faylini ochishdan boshlanadi. 😉
Sploitus Agency
Photo
Meni music botim ham shunaqa qiyinchiliklar bilan yuklab berar edi, bundan ham murakkabroq
Forwarded from Abdulaziz Omonov | Blog (Abdulaziz)
Faang Prep #7-8 — Stack

Bu darslarda Stack mavzusida masalalar yechdik:

- Baseball Game
- Valid Parentheses
- Implement Stack Using Queues
- Implement Queue using Stacks
- Min Stack

Har dushanba , chorshanba va shanba talabalar bilan o'rganamiz. Kuzatib boring va FAANGga tayyorlanayotgan tanishlaringizga yuboring.

1-qism: https://www.youtube.com/watch?v=kpNCQpr2VZg&feature=youtu.be
2-qism: https://www.youtube.com/watch?v=iiZRBjIwaCY
👍1