Skip to content

Instantly share code, notes, and snippets.

View RaminMammadzada's full-sized avatar
🔬
Engineering is a wonderful thing if one does not have to earn one's living at it

Ramin RaminMammadzada

🔬
Engineering is a wonderful thing if one does not have to earn one's living at it
View GitHub Profile
@RaminMammadzada
RaminMammadzada / CodeSignal-RotateImage.txt
Last active September 8, 2022 08:34
CodeSignal - rotateImage.py
Note: Try to solve this task in-place (with O(1) additional memory), since this is what you'll be asked to do during an interview.
You are given an n x n 2D matrix that represents an image. Rotate the image by 90 degrees (clockwise).
Example
For
a = [[1, 2, 3],
@RaminMammadzada
RaminMammadzada / Example usage of media queries in CSS
Created September 10, 2020 14:38
Example usage of media queries in CSS
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
background-color: lightgreen;
}
@media only screen and (max-width: 400px) {
@RaminMammadzada
RaminMammadzada / homebrew-permissions-issue.md
Created August 8, 2020 15:18 — forked from irazasyed/homebrew-permissions-issue.md
Homebrew: Permissions Denied Issue Fix (OS X / macOS)

Homebrew Permissions Denied Issues Solution

sudo chown -R $(whoami) $(brew --prefix)/*

@RaminMammadzada
RaminMammadzada / Creating a repository from command line
Created July 6, 2020 05:18
Creating a repository from command line
mkdir myDirName #this is the name of your directory
cd /myDirName
git init
touch readME.md #this is to create an initial file to push
git commit -m "enter commit message here"
git remote add origin git@github.com:YOUR_USERNAME/myDirName.git
curl -u USERNAME:PASSWORD https://api.github.com/user/repos -d '{"name":"myDirName"}' #this will create the repo in github.
# if you haven't generated and SSH key for github access then follow these steps, otherwise you're good to push your shit to github.
@RaminMammadzada
RaminMammadzada / Letter Frequency Finder
Created April 12, 2020 07:42
The frequencies of the letter in the text
"""
The following English text was encrypted using a substitution cipher that shuffles the alphabet rather than just shifting it.
Can you find what the following letters l and h stand for in the following text ?
hm al, mo tmh hm al, huvh gn hul jzlnhgmt:
qulhulo 'hgn tmaxlo gt hul cgty hm nzrrlo
hul nxgtsn vty voomqn mr mzhovslmzn rmohztl,
mo hm hvel vocn vsvgtnh v nlv mr homzaxln
vty ak mppmngts lty hulc?
hm ygl: hm nxllp;
"""
Brute-force the following Caesar’s cipher, and find
the plaintext and key of the following
message: kyvtrmrcipnzccrkkrtbwifdkyvefikynvjkrkeffe
"""
alphabet = "abcdefghijklmnopqrstuvwxyz"
def encrypt(plaintext, k):
ciphertext = []
@RaminMammadzada
RaminMammadzada / Timing Attack for 4 digits password
Created April 12, 2020 06:47
Timing Attack for 4 digits password
"""
The function check_password(password) is used by a safe with 4-digits passwords, and is
susceptible to timing attacks. More specifically, it takes it around 0.1 seconds to check
one digit – so brute-forcing all the possible combinations will take around 1,500 hours.
Can you implement a way to crack its password in less than a minute?
"""
import time
import sys # ignore
@RaminMammadzada
RaminMammadzada / Ceaser Cipher in Python
Last active April 12, 2020 06:48
Ceaser Cipher in Python
"""
Implement Caesar’s cipher: implement a function encrypt that
given a plaintext string and a key 𝑘 (how many letters to shift),
returns a ciphertext where each character is shifted 𝑘 places.
(You can assume all characters are lowercase letters, with no punctuation or spaces.)
"""
alphabet = 'abcdefghijklmnopqrstuvwxyz'
def encrypt(plaintext="hithere", k=4):
@RaminMammadzada
RaminMammadzada / Neural Network App on Music Industry
Created January 2, 2019 19:25
Neural Network App on Music Industry
1) Piano Genie article
https://arxiv.org/abs/1810.05246
2) Neural Translation of Musical Style
https://arxiv.org/abs/1708.03535
3) Google’s AI-powered Piano Genie lets anyone improvise perfectly by bashing buttons
https://www.theverge.com/2018/10/16/17982596/google-magenta-ai-piano-genie-improvisation-neural-networks
4) Piano Genie: An Intelligent Musical Interface
@RaminMammadzada
RaminMammadzada / Clone all repos at once
Last active December 26, 2018 20:23
Script to clone all of the repos at once
Script:
curl -s https://api.github.com/users/user/repos | grep \"clone_url\" | awk '{print $2}' | sed -e 's/"//g' -e 's/,//g' | xargs -n1 git clone
More info:
https://blog.scottlowe.org/2018/07/19/cloning-all-repositories-in-a-github-organization/