Skip to content

Instantly share code, notes, and snippets.

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

Palash Tyagi Magnus167

🧘
thinking...
View GitHub Profile
@1kastner
1kastner / run_python_script_in_conda_env.bat
Last active March 5, 2024 08:27 — forked from maximlt/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
@Denbergvanthijs
Denbergvanthijs / donut.py
Last active June 5, 2024 11:22
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
program what3word;
{$APPTYPE CONSOLE}
{$R *.res}
uses IdHashMessageDigest,
System.SysUtils;
const
x: integer = 15;
@superllama
superllama / asm.vbs
Created February 25, 2020 00:28
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"
@nguyendv
nguyendv / multi-handlers-logger.py
Last active January 4, 2024 16:38
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')
@martinsotir
martinsotir / conda_4.6_powershell.md
Last active June 26, 2024 06:37
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.

@nikhilkumarsingh
nikhilkumarsingh / paint.py
Created November 3, 2017 16:26
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):
@why-not
why-not / gist:4582705
Last active July 3, 2024 01:12
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])