Skip to content

Instantly share code, notes, and snippets.

View Ddedalus's full-sized avatar

Hubert Bereś Ddedalus

View GitHub Profile
@Ddedalus
Ddedalus / hw2.py
Created December 8, 2019 22:00
Plotly: markers on line plot with express
import plotly.express as px
fig = px.line(y=[1,2,3,2,1])
fig.data[0].update(mode='lines+markers')
fig.show()
# or fig.update_traces(mode='lines+markers') for all traces
@Ddedalus
Ddedalus / homework.py
Created November 4, 2019 13:20
Plotly modify default layout
import plotly.graph_objects as go
import plotly.io as io
fig = go.Figure()
fig.update_layout(legend=dict(orientation = "h",
xanchor = "center",
x = 0.5),
margin=dict(l=20, r=20, t=20, b=20))
templated_fig = pio.to_templated(fig)
@Ddedalus
Ddedalus / homework.py
Created November 4, 2019 13:17
Plotly disable interactive rendering
import plotly.io as pio
# see docs at https://plot.ly/python/renderers/
# render and display plots as png images
pio.renderers.default = "png"
# override the renderer for a specific figure
fig.show(renderer="notebook_connected")
@Ddedalus
Ddedalus / load.bat
Created November 4, 2019 13:13
Disable web in Windows 10 start menu
:: See https://superuser.com/a/1325836
reg add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Search /f /v BingSearchEnabled /t REG_DWORD /d 0
reg add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Search /f /v AllowSearchToUseLocation /t REG_DWORD /d 0
reg add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Search /f /v CortanaConsent /t REG_DWORD /d 0
@Ddedalus
Ddedalus / Bonus-assignment1.R
Created October 26, 2019 14:46
R+plotly: view data for highlighte points
# Credit to MLaovie, https://stackoverflow.com/a/50766967/3279307
library(plotly)
library(crosstalk) # update HTML widgets over a common dataset
library(DT)
sd <- SharedData$new(iris) # put your dataframe here
a <- plot_ly(sd, x = ~Sepal.Width, y = ~Petal.Width) %>%
add_markers(alpha = 0.5) %>%
@Ddedalus
Ddedalus / jupyterify.py
Last active March 30, 2020 21:37
Jupyterify a VS Code interactive python file
# usage: jupyterify in_file.py out_file.py
import re
import sys
try:
in_path = sys.argv[1]
out_path = sys.argv[2]
except:
print('Please pass input and output path!')
@Ddedalus
Ddedalus / psconfig.ps1
Created August 15, 2019 17:13
Set execution policy in PowerShell
# must run from the shell:
# Policies are described here:
# https://docs.microsoft.com/en-gb/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-6
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
@Ddedalus
Ddedalus / generate_webhook.py
Created August 2, 2019 10:42
Generate private key in Python over arbitrary alphabet
import secrets
import string
alphabet = string.ascii_letters + string.digits
key = ''.join(secrets.choice(alphabet) for i in range(40))
print(key)
# source: https://www.geeksforgeeks.org/secrets-python-module-generate-secure-random-numbers/
@Ddedalus
Ddedalus / outlook.py
Created January 15, 2019 00:48
Properties of Outlook API object
def prop(obj):
return sorted( obj._prop_map_get_.keys())
@Ddedalus
Ddedalus / list_environment.py
Created January 4, 2019 23:33
Dump all variables to a json
__loc__ = locals().copy()
def __list_env__(loc):
import sys
import json
from numpy import ndarray
from types import ModuleType
def serialize(x):
if isinstance(x, ndarray):
return str(x.tolist())
else: