Skip to content

Instantly share code, notes, and snippets.

while (True):
vp.rate(500)
#Calculte the force using gravitationalForce function
star.force = gravitationalForce(star,planet1)+gravitationalForce(star,planet2)+gravitationalForce(star,planet3)
planet1.force = gravitationalForce(planet1,star)+gravitationalForce(planet1,planet2)+gravitationalForce(planet1,planet3)
planet2.force = gravitationalForce(planet2,star)+gravitationalForce(planet2,planet1)+gravitationalForce(planet2,planet3)
planet3.force = gravitationalForce(planet3,star)+gravitationalForce(planet3,planet1)+gravitationalForce(planet3,planet2)
#Update momentum, position and time
@simrit1
simrit1 / crawl_valence_arousal_dataset.py
Created April 10, 2022 18:17 — forked from MaxHilsdorf/crawl_valence_arousal_dataset.py
This code crawls a dataset, which can be used for mood-based recommendations, from the Spotify API
#################
## PREPARATION ##
#################
# Import modules
import sys
# If your authentification script is not in the project directory
# append its folder to sys.path
sys.path.append("../spotify_api_web_app")
import authorization
import asyncio
from tortoise import Tortoise, run_async, connections
from tortoise.models import Model
from tortoise import fields
import random
import time
class Employees(Model):
ID = fields.IntField(pk=True)
NAME = fields.TextField()
AGE = fields.IntField()
@simrit1
simrit1 / complex.py
Created June 22, 2022 07:11 — forked from bellbind/complex.py
[python3] Calc Riemann Zeta function
# complex arith for programming with other languages
# - required functions: exp(f), log(f), sin(f), cos(f), atan2(f), pow(f1, f2)
import math
# [equality for complex]
def ceq(a, b):
return a.real == b.real and a.imag == b.imag
# [add, sub, mul for complex]
[package]
name = "snake_game"
version = "0.1.0"
authors = ["youcodethings <spyr1014@gmail.com>"]
[dependencies]
piston = "0.36.0"
piston2d-graphics = "0.26.0"
pistoncore-glutin_window = "0.45.0"
piston2d-opengl_graphics = "0.52.0"
@simrit1
simrit1 / modern-geospatial-python.md
Created June 28, 2022 18:03 — forked from rukku/modern-geospatial-python.md
Modern remote sensing image processing with Python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#########################
# NumPy Raster Calculator
# -----------------------
# Purpose: The purpose of this Python script is to use ArcGIS's arcpy package along with the Python library numpy to convert Landsat thermal bands from digital numbers to Top of Atmosphere (ToA) brightness-temperature values that provide pixel temperature in degrees Celsius.
# Purpose #2: The second purpose is that it allows some work to be done on rasters without the need for the Spatial Analyst extension
#
# Requirements: ESRI ArcGIS arcpy; Python 2.7.x; numpy; Landsat data
# ArcPy takes care of the dirty work of conversions and geospatial stuff and I have ArcGIS installed, hence it's use.
#########################
@simrit1
simrit1 / subnet.py
Created July 13, 2022 17:21 — forked from vndmtrx/subnet.py
Python 3 simple subnet calculator
#!/usr/bin/env python3
# Use: ./subnet.py <ip/cidr>
# Alt: ./subnet.py <ip> <mask>
import sys
if __name__=="__main__":
addr = [0, 0, 0, 0]
mask = [0, 0, 0, 0]
cidr = 0
from sklearn.neighbors import KNeighborsRegressor
from sklearn.linear_model import LogisticRegressionCV
def X_learner(df, model, y, D, X):
temp = dgp.generate_data(true_te=True).sort_values(X)
# Mu
mu0 = model.fit(temp.loc[temp[D]==0, X], temp.loc[temp[D]==0, y])
temp['mu0_hat_'] = mu0.predict(temp[X])
mu1 = model.fit(temp.loc[temp[D]==1, X], temp.loc[temp[D]==1, y])