Skip to content

Instantly share code, notes, and snippets.

View 4e1e0603's full-sized avatar
🎯
I may be slow to respond.

David Landa 4e1e0603

🎯
I may be slow to respond.
  • Prague, Czech Republic
View GitHub Profile
@4e1e0603
4e1e0603 / shell-setup.ps1
Created June 27, 2023 14:05 — forked from mikepruett3/shell-setup.ps1
Packages to install via scoop, winget, choco, and other tools...
<#
.SYNOPSIS
Script to Initialize my custom powershell setup.
.DESCRIPTION
Script uses scoop
.NOTES
**NOTE** Will configure the Execution Policy for the "CurrentUser" to Unrestricted.
Author: Mike Pruett
Date: October 18th, 2018
@4e1e0603
4e1e0603 / rules_to_problem_solving.md
Created June 11, 2023 06:13 — forked from neaxi/rules_to_problem_solving.md
Rules to problem solving

Rules to Problem Solving

(Unknown author)

Rule #1: Don't assume you understand the problem

This is one of the classic mistakes of problem solving - you think you understand what's going on, but you didn't look deep enough or get enough information to really get it. Before starting to solve any problem, be sure you spend some time and be absolutely sure you understand exactly what's going in.

Rule #2: Don't assume that the person who reported the problem understands the problem either

@4e1e0603
4e1e0603 / Cahn-Hilliard.py
Created August 12, 2021 14:38
Cahn-Hilliard
@overrides
def solve(self): #-> np.ndarray:
"""
The sequential version of Cahn-Hilliard solver.
Update a conserved order parameter, in our case, the concetration field $c(r, t)$.
Calculate free energy derivative at domain nodes.
The eight neighbour nodes of the central node (C) are north (N), south (S),
@4e1e0603
4e1e0603 / Comment for Functional Python Article.py
Last active August 6, 2021 08:19
Comment for Functional Python Article
# Functional composition with `>>` operator.
class Value:
def __init__(self, value) -> None:
self.value = value
def __rshift__(self, that):
print(f"{that.__name__}({self.value})")
return Value(that(self.value))
@4e1e0603
4e1e0603 / python-virtual-environment.md
Last active November 24, 2023 16:50
How to create and activate and use Python virtual environment

Unix

source .venv\bin\activate

Windows

.venv\Scripts\activate
def init(params: Parameters, T0: Temperature, q: HeatFlow, ts:float) -> np.array:
"""
The time independent solution to heat equation.
:param params: The model parameters.
:param T0: The surface temperature [°C].
:param q: The mantle heat flow density [mW/m^2].
:param ts: The time step in years.
:returns: The temperature field [°C].
"""
@4e1e0603
4e1e0603 / rename_pdf.py
Created November 7, 2020 08:08 — forked from ipudu/rename_pdf.py
Rename an academic article pdf with human readable format
import sys
import requests
import PyPDF2
import requests
import os
crossref = 'http://api.crossref.org/'
def rename(pdf):
"""Rename an academic article pdf file with human readable format

Python assignment expression :=

In Python 3.8 was introduced an assignment expression (walrus operator :=) which can be used as in the example below.

if x := 1:
  print(bool(x))

The assignment statement cannot be used as in the previous example.

@4e1e0603
4e1e0603 / state_machine_switch.py
Last active February 11, 2020 08:51
Example of State Machine with Switch Statement
"""
Simple state machine example and switch emulation.
"""
from enum import Enum
from typing import Iterable
class State(Enum):
@4e1e0603
4e1e0603 / __main__.py
Created March 31, 2019 15:42 — forked from linuxluigi/__main__.py
Python __main__.py parser example
import argparse
# import data2tabshop
# from data2tabshop import __version__
__version__ = '0.1.0'
__author__ = u'Steffen Exler'
def get_parser():