Skip to content

Instantly share code, notes, and snippets.

View rudrathegreat's full-sized avatar
🎥
Running a YouTube Channel!

Rudra Sekhri rudrathegreat

🎥
Running a YouTube Channel!
View GitHub Profile
@ProtichiChatterjee
ProtichiChatterjee / PY0101EN-2-2-Lists.ipynb
Created September 27, 2020 08:22
Created on Skills Network Labs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mfilipelino
mfilipelino / prime.py
Last active November 25, 2022 14:26
is prime
def is_prime(number):
if number <= 0:
return False
if number == 1:
return True
elif number == 2:
return True
else:
for i in range(2, number):
if number % i == 0:
@honux77
honux77 / ec2-slack-user-data.sh
Last active November 24, 2018 05:42
slack + AWS example
#!/bin/bash
# put this in ec2 ubuntu user-data
mkdir /home/ubuntu/script/
cat <<'EOF' >> /home/ubuntu/script/slack.sh
#!/bin/bash
ip=`/usr/bin/curl -s -w '\n' http://169.254.169.254/latest/meta-data/public-ipv4`
instance=`/usr/bin/curl -s -w '\n' http://169.254.169.254/latest/meta-data/instance-id`
@akey7
akey7 / find_median.py
Created October 19, 2018 02:44
Find a median in a Pyton list of integers or floats
def median(xs):
"""
When given a standard Python list of numbers, this function will
return the median value. There are a few cases to consider:
1. xs is an empty list: return None
2. A list with one element: returns that element
3. A list with an odd number of elements: Returns the middle value.
@akey7
akey7 / find_mode.py
Created October 19, 2018 02:42
Mode finding's in Python lists
def mode(xs):
"""
This returns the mode of the values in xs. xs is a standard
Python list with discrete values, which can be of any hashable
value.
Fo this problem, think about using a dictionary in some way.
What could be the keys? The values? Also remember that dictionaries
are UNORDERED--in other words, there is no guaranteed order.
@akey7
akey7 / sine_animation.py
Created May 3, 2018 16:14
PY: Animated GIF for sine wave
# See for tiao.io/posts/notebooks/save-matplotlib-animations-as-gifs/ more information and notes below
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import animation, rc
from IPython.display import HTML, Image
# equivalent to rcParams['animation.html'] = 'html5'
rc('animation', html='html5')
fig, ax = plt.subplots()
@akey7
akey7 / numpy_array_to_wav_file.py
Created March 31, 2018 02:55
Generate a .wav sound file from a NumPy array.
import numpy as np
from scipy.io.wavfile import write
# Samples per second
sps = 44100
# Frequency / pitch of the sine wave
freq_hz = 440.0
# Duration
@CMCDragonkai
CMCDragonkai / Matplotlib Backends.md
Last active February 12, 2023 13:22
Matplotlib Backends #matplotlib #python

Matplotlib Backends

Matplotlib is a plotting library. It relies on some backend to actually render the plots. The default backend is the agg backend. This backend only renders PNGs. On Jupyter notebooks the matplotlib backends are special as they are rendered to the browser. Generally you will not need to explicitly set the backend on a Jupyter notebook. This does introduce a discrepancy between code that runs in Jupyter and code that runs as a script natively in the Python interpreter. So you need to understand that the 2 environments are not the same

@Overdrivr
Overdrivr / Plot.py
Created February 4, 2016 13:38
PyQtGraph animated sine and cosine functions - real smooth
# -*- coding: utf-8 -*-
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
from numpy import arange, sin, cos, pi
import pyqtgraph as pg
import sys
class Plot2D():
def __init__(self):
self.traces = dict()
@itsmattsoria
itsmattsoria / gistfil1.textile
Last active April 22, 2024 12:37
Mac Terminal Cheat Sheet

SHORTCUTS

Key/Command Description
Tab Auto-complete files and folder names
Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + U Clear the line before the cursor
Ctrl + K Clear the line after the cursor
Ctrl + W Delete the word before the cursor
Ctrl + T Swap the last two characters before the cursor