Skip to content

Instantly share code, notes, and snippets.

View Magnus167's full-sized avatar
🧘
thinking...

Palash Tyagi Magnus167

🧘
thinking...
View GitHub Profile
@Magnus167
Magnus167 / donut.py
Created June 21, 2021 02:49 — forked from Denbergvanthijs/donut.py
3D spinning donut in Python. Based on the pseudocode from: https://www.a1k0n.net/2011/07/20/donut-math.html
import numpy as np
screen_size = 40
theta_spacing = 0.07
phi_spacing = 0.02
illumination = np.fromiter(".,-~:;=!*#$@", dtype="<U1")
A = 1
B = 1
R1 = 1
@Magnus167
Magnus167 / asm.vbs
Created June 21, 2021 03:02 — forked from superllama/asm.vbs
An x86 assembler... in VBScript, for some reason. Includes two unfinished EXE projects.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Hit Ctrl+F and find the second instance of "here"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
exetxt = ""
loc = 0
eax="eax":ecx="ecx":edx="edx":ebx="ebx":esp="esp":ebp="ebp":esi="esi":edi="edi"
cs="cs":ds="ds"
al="al":cl="cl":dl="dl":bl="bl"
ah="ah":ch="ch":dh="dh":bh="bh"
ax="ax":cx="cx":dx="dx":bx="bx":sp="sp":bp="bp":si="si":di="di"
@Magnus167
Magnus167 / webdriver-packed-extension.py
Created July 8, 2021 17:48 — forked from cgoldberg/webdriver-packed-extension.py
Python - Selenium WebDriver - Installing a packed Chrome Extension
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
packed_extension_path = '/path/to/packed/extension.crx'
options = Options()
options.add_extension(packed_extension_path)
driver = webdriver.Chrome(options=options)
@Magnus167
Magnus167 / html2docx.bat
Created December 22, 2021 13:25 — forked from pagelab/html2docx.bat
Batch file to convert HTML files to Word docx with Pandoc
:: This batch file converts HTML files in a folder to docx.
:: It requires Pandoc, and a list of files to convert
:: named file-list, in which each file is on a separate line,
:: and contains no spaces in the filename.
::
:: Don't show these commands to the user
@ECHO off
:: Set the title of the window
TITLE Convert html to docx
:: This thing that's necessary.
@Magnus167
Magnus167 / gist:f3b3d441e22fb988e2cd902240f7833a
Created March 7, 2022 01:10 — forked from why-not/gist:4582705
Pandas recipe. I find pandas indexing counter intuitive, perhaps my intuitions were shaped by many years in the imperative world. I am collecting some recipes to do things quickly in pandas & to jog my memory.
"""making a dataframe"""
df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB'))
"""quick way to create an interesting data frame to try things out"""
df = pd.DataFrame(np.random.randn(5, 4), columns=['a', 'b', 'c', 'd'])
"""convert a dictionary into a DataFrame"""
"""make the keys into columns"""
df = pd.DataFrame(dic, index=[0])
@Magnus167
Magnus167 / paint.py
Created March 28, 2022 23:19 — forked from nikhilkumarsingh/paint.py
A simple paint application using tkinter in Python 3
from tkinter import *
from tkinter.colorchooser import askcolor
class Paint(object):
DEFAULT_PEN_SIZE = 5.0
DEFAULT_COLOR = 'black'
def __init__(self):
@Magnus167
Magnus167 / conda_4.6_powershell.md
Created September 23, 2022 09:37 — forked from martinsotir/conda_4.6_powershell.md
Enable conda in powershell

Enabling conda in Windows Powershell

First, in an administrator command prompt, enable unrestricted Powershell script execution (see About Execution Policies):

set-executionpolicy unrestricted

Then makes sure that the conda Script directory in is your Path.

@Magnus167
Magnus167 / run_python_script_in_conda_env.bat
Created September 30, 2022 09:41 — forked from 1kastner/run_python_script_in_conda_env.bat
Run a Python script in a conda environment from a batch file
@ECHO OFF
SETLOCAL EnableDelayedExpansion
REM Insert your conda env here
SET CONDA_ENV=MY_DESIRED_CONDA_ENV
CALL :activate_conda_env
REM Insert your python script here
@Magnus167
Magnus167 / 01-explanation-of-python-logging-and-the-root-logger.md
Created October 24, 2022 15:50 — forked from gene1wood/01-explanation-of-python-logging-and-the-root-logger.md
Explanation of the relationship between python logging root logger and other loggers

Explanation of the relationship between python logging root logger and other loggers

@Magnus167
Magnus167 / multi-handlers-logger.py
Created December 15, 2022 17:48 — forked from nguyendv/multi-handlers-logger.py
Python logger with multiple handlers (stream, file, etc.), so you can write log to multiple targets at once
import logging
from logging.handlers import RotatingFileHandler
def setup_logger():
MAX_BYTES = 10000000 # Maximum size for a log file
BACKUP_COUNT = 9 # Maximum number of old log files
# The name should be unique, so you can get in in other places
# by calling `logger = logging.getLogger('com.dvnguyen.logger.example')
logger = logging.getLogger('com.dvnguyen.logger.example')