Skip to content

Instantly share code, notes, and snippets.

Avatar

Ram Narasimhan Ram-N

View GitHub Profile
@Ram-N
Ram-N / wordcloud.py
Created Aug 27, 2020
Create a Simple Wordcloud using Donald Trump's Tweets
View wordcloud.py
import json
from wordcloud import WordCloud
import matplotlib.pyplot as plt
with open('data/trump_tweets/condensed_2018.json') as f:
data = json.load(f)
type(data), len(data)
@Ram-N
Ram-N / cardioid.py
Created Aug 24, 2020
How to Draw a Cardioid using Processing.py
View cardioid.py
w, h = 800, 800
def setup():
size(w, h)
stroke(0, 0, 250) # blue
num_steps = 200
step = TWO_PI / num_steps
@Ram-N
Ram-N / Ball_trapeze_gif_loop.py
Created Jul 9, 2020
Ball_trapeze_gif_loop.py
View Ball_trapeze_gif_loop.py
w, h = 1000, 800
class Ball(object):
def __init__(self,_id, _x, _y, _vx=0, _vy=0, _dir='UP'):
self.x, self.y = _x, _y
self.vx, self.vy = _vx, _vy
self.id = _id
self.dir = _dir #'UP', 'DOWN', "RIGHT", "LEFT"
self.av = 0
@Ram-N
Ram-N / bw_noise_color.py
Last active Jul 7, 2020
Perlin Noise Coloring
View bw_noise_color.py
# The noise value was calculated at each pixel,
# using Processing’s built-in noise function.
# This value was scaled up (by a factor of 10 to 100) and rounded,
# yielding an integer for every pixel in the frame.
# Colors were designated based on this number using a switch.
# Finally, a point/dot was drawn at each pixel, in the assigned color.
# The greater the scaling factor, the thinner and more numerous the noise bands.
# Creates a 2D List of 0's, nCols x nRows large
@Ram-N
Ram-N / ball.py
Last active Jun 29, 2020
Processing_py - Balls criss-crossing
View ball.py
class Ball(object):
def __init__(self,_id, _x, _y, _vx=0, _vy=0):
self.x, self.y = _x, _y
self.vx, self.vy = _vx, _vy
self.id = _id
#store the starting coords of each ball. For relaunching.
self.startx, self.starty = _x, _y
self.active = False
@Ram-N
Ram-N / 2_circles_rotating_around_a_point.py
Last active Jun 30, 2020
Py Processing Scripts - Basics
View 2_circles_rotating_around_a_point.py
radius = 100
def setup():
size(800, 600)
background(255)
smooth()
noStroke()
fill(0, 0, 200)
frameRate(100)
@Ram-N
Ram-N / Song_Finder.py
Created Jul 9, 2018
Find Songs given a list of words
View Song_Finder.py
import pandas as pd
def print_songs_found(songs_column, clue_words):
for song in songs_column:
try:
songwords = [x.lower() for x in song.split()]
#print(songwords)
if all(word in clue_words for word in songwords):
print(songwords)
except:
@Ram-N
Ram-N / ColNames.R
Created May 30, 2018
Using paste0 with length=option
View ColNames.R
i <- 1:50
b <- 1:5
ColNames <- paste0("X_", i, "_", rep(b, each=length(i)))
@Ram-N
Ram-N / ColNames.R
Created May 30, 2018
Using paste0 with length=option
View ColNames.R
i <- 1:50
b <- 1:5
ColNames <- paste0("X_", i, "_", rep(b, each=length(i)))
View test.R
df[, !(colnames(df) %in% c("x","bar","foo"))]
You can’t perform that action at this time.