This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from datetime import date | |
from typing import List | |
from functools import cache | |
from warnings import warn | |
import re | |
MEMBERSHIP_URL = 'https://en.wikipedia.org/wiki/Member_state_of_the_European_Union' | |
MEMBERSHIP_URL_PERM_LINK = 'https://en.wikipedia.org/w/index.php?title=Member_state_of_the_European_Union&oldid=1184106841' | |
CANONICAL_WIKI_DATE = date(2023, 11, 11) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from bokeh.io import output_notebook | |
from bokeh.plotting import figure, show, ColumnDataSource | |
from bokeh.models import GeoJSONDataSource | |
output_notebook() | |
# If you don't have the file yet | |
import requests as rq |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[clojure.core.async :refer [chan, go, <!, >!, >!!, <!!]]) | |
;=> nil | |
(defn print-channel | |
[channel-msg in] | |
(let [out (chan 1)] | |
(go (let [msg (<! in)] | |
((println channel-msg msg) | |
(>! out msg)))) | |
out | |
)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gpu info as a dict | |
# from https://gist.github.com/takuseno/2958caf1cb5e74314a9b5971999182b2 | |
from subprocess import Popen, PIPE | |
from xml.etree.ElementTree import fromstring | |
def nvidia_smi_xml(): | |
p = Popen(['nvidia-smi', '-q', '-x'], stdout=PIPE) | |
outs, errors = p.communicate() | |
return fromstring(outs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Prints notebook's pid, memory and gpu memory utilization | |
The code is from https://stackoverflow.com/a/44936664/996379 | |
Also gpu code is from https://gist.github.com/takuseno/2958caf1cb5e74314a9b5971999182b2 | |
Usage: | |
python monitor_notebooks.py $notebook_token | |
if token is not supplied, it will prompt you for a token. | |
""" | |
import os | |
import os.path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from python | |
RUN pip install pandas > /dev/null | |
ARG NEW="false" | |
RUN if [ ${NEW} = "true" ]; then pip install git+https://github.com/2torus/pandas_market_calendars.git@cache-holidays > /dev/null; else pip install pandas_market_calendars==1.4.2 > /dev/null; fi | |
RUN echo "import pandas as pd \n\ | |
from random import sample, seed \n\ | |
import time \n\ | |
random_dates = pd.date_range('2000-1-1', '2019-1-1', freq='D') \n\ | |
seed(0xDEED) \n\ | |
random_dates = sample(random_dates.to_list(), 101) \n\ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(ex2_18). | |
-export([double/1, filter/1, median/1, modes/1]). | |
% tail recursive solutions, so they need reverse | |
% there is probably a library function for that. | |
reverse([], S) -> S; | |
reverse([X|Xs], S) -> reverse(Xs, [X|S]). | |
double(X) -> reverse(double(X,[]), []). | |
double([], L) -> L; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(ex2_15). | |
-export([prod/1, prod_tail/1, maxx/1, max_tail/1]). | |
prod([]) -> 1; | |
prod([X|Xs]) -> X * prod(Xs). | |
prod_tail(X) -> prod_tail(X, 1). | |
prod_tail([], P) -> P; | |
prod_tail([X|Xs], P) -> prod_tail(Xs, X * P). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(ex2). | |
-export([max_three/3, how_many_equal/3, how_many_equal_test/0, xor1/2, xor2/2, xor3/2]). | |
xor1(true, B) -> | |
not B; | |
xor1(_, B) -> | |
B. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(first). | |
-export([double/1, treble/1, square/1,perimeter/3, area/3]). | |
mult(X, Y) -> | |
X * Y. | |
double(X) -> | |
mult(2,X). | |
treble(X) -> | |
mult(3, X). | |
square(X) -> |
NewerOlder