Skip to content

Instantly share code, notes, and snippets.

View ssaadh's full-sized avatar
🎯
Focusing

Saadh ssaadh

🎯
Focusing
View GitHub Profile
def fn_d(n: int) -> int:
if n <= 1:
return 1
count = 0
for x in range(n):
count += x
return fn_d(n//2) + fn_d(n // 2) + count
# runtime: O(n log n)
# The loop for adding up count iterates (n) times doing constant addition operation. This is O(n).
#assume no duplicates in array
def searchRotatedArray(arr, target):
#runtime - O(lgN)
#space - O(1)
lo = 0
hi = len(arr) - 1
while(lo <= hi):
mid = (lo + hi)//2
#if we find the element then we are done
if arr[mid] == target:
class ListNode:
def __init__(self, key, val, nxt):
self.key = key
self.val = val
self.next = nxt
class MyHashMap:
def __init__(self):
self.size = 19997
self.mult = 12582917
@ssaadh
ssaadh / Binary Search Template.py
Created February 27, 2023 19:57
Hints when to Use Binary Search in an interview.. - When an array or matrix is sorted or partially sorted that might be a sign that you want to use binary search - When the O(N) solution is obvious or the interviewer is looking for faster than O(N). Key Takeaways: - Search Condition can be determined without comparing to the element's neighbors …
def binarySearch(nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: int
"""
if len(nums) == 0:
return -1
lo, hi= 0, len(nums) - 1

Duplicate/Copy zoom.us app to a 2nd location. I did /Users/Shared/Applications.

In current GUI account, open Zoom from /Users/Shared/Applications aka 2nd location.

In terminal, I did su second_standard_user. Ran /Applications/zoom.us.app/Contents/MacOS/zoom.us.

Things from Safari will open up via this 2nd user zoom. To open things from your current GUI user. In terminal: open -a /Users/Shared/Applications/zoom.us.app 'https://us02web.zoom.us/j/2401234567?pwd=PW’

@ssaadh
ssaadh / zoomers_try-to-force-create-local-user-keychains-folder.sh
Last active October 4, 2020 19:09
Zoomers -- Try to force create local user's Keychains folder
# Open Terminal.app up. Enter these commands in there.
# For sudo commands, enter your current mac user admin password and press enter. No text will show up as you enter it.
# Verify there's nothing that comes up. It should say "No such file or directory" both times
ls -la ~/Library/Keychains
sudo ls -la ~/Library/Keychains
# Try to force create the folder and give it usual permissions
sudo mkdir ~/Library/Keychains
@ssaadh
ssaadh / install-papertrailapp-remote_syslog2.sh
Last active April 22, 2020 12:37
Install Papertrail App's remote_syslog2[0] on macOS for a specific NodeJS project. [0] https://github.com/papertrail/remote_syslog2
cd ~/tmp-moi
wget https://github.com/papertrail/remote_syslog2/releases/download/v0.20/remote_syslog_darwin_amd64.tar.gz
tar -xvzf remote_syslog_darwin_amd64.tar.gz
cd ./remote_syslog
## OG
# sudo cp ./remote_syslog /usr/local/bin
# sudo cp example_config.yml /etc/log_files.yml
# sudo vim /etc/log_files.yml
@ssaadh
ssaadh / screencapture-obs-agent.plist
Created April 20, 2020 03:35
I'm doing this on Mac using launchctl. Can include the actual plist as well. Really basic though. Runs every 10 seconds. I turn it off when not running OBS. (launchctl unload screencapture-obs-agent.plist)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/local/sbin</string>
</dict>
<key>Label</key>
@ssaadh
ssaadh / reddit-sb-minimal-html-common-search-bonus-terms-and-links.html
Created April 19, 2020 17:48
reddit-sb-minimal-html-common-search-bonus-terms-and-links.html
{"version":1,"resource":"file:///Users/makeanothertelephonecall/Dropbox/Learning/epic-werk/proj-gh/app/sockets/src/core/.vscode/settings.json","entries":[{"id":"nV6c.json","timestamp":1653589690694}]}