Skip to content

Instantly share code, notes, and snippets.

View AllanLRH's full-sized avatar

Allan L. R. Hansen AllanLRH

  • Copenhagen, Denmark
View GitHub Profile
% ****************************************************************************
% * This demonstrate how to apply blur to an RGB-image, and create a third *
% * image which is composed partly of the original unblurred image, and *
% * partly of the blurred image. *
% ****************************************************************************
% Read example image built into MATLAB
I0 = double(imread('saturn.png'));
@AllanLRH
AllanLRH / doNotUpdateSpotify.sh
Last active May 18, 2022 06:05
Disable Spotify autoupdate on Mac OS X (testet on Yosemite).
# This script prevents Spotifys Autoupdating on OS X (testet on Yosemite)
# Based on this tutorial:
# http://supraliminal.net/blog/2013/4/21/how-to-revert-back-to-the-older-better-spotify-client
#
# This script must be run as root:
# sudo sh doNotUpdateSpotify.sh
#
FILE="/tmp/out.$$"
if [ "$(id -u)" != "0" ]; then
UIZI-9THJRqKJYlZKFx5Tp%d?NDSwG
@AllanLRH
AllanLRH / esbilon.py
Last active December 23, 2020 20:16
Esbilon
b = np.arange(0, 36)
m = b[:, None, None] + b[None, :, None] + b[None, None, :]
mask = m ==35
ix = np.where(mask)
ans = np.stack(ix, axis=1)
assert (ans.sum(axis=1) == 35).all(), "Oh no! wrong resuult :'("
print(ans.shape, end='\n\n-----------\n\n')
print(*ans, sep='\n')
@AllanLRH
AllanLRH / plotCausalGraph.py
Created April 7, 2017 12:24 — forked from nimezhu/plotCausalGraph.py
plot directed graph (python matplotlib)
#!/usr/bin/python
# programmer : zhuxp
# usage:
import sys
from getopt import getopt
import networkx as nx
import matplotlib.pyplot as plt
def show_help():
print >>sys.stderr,"\n\nplotCausalGraph.py: drawing causal graph from LiNGAM output equation matrix B"
print >>sys.stderr,"Library Dependence: networkx , matplotlib\n\n"
@AllanLRH
AllanLRH / get_sql_schema_information.sql
Created April 1, 2020 13:41
Get SQL scheme information for table
SELECT COLUMN_NAME
,IS_NULLABLE
,DATA_TYPE
,CHARACTER_MAXIMUM_LENGTH
,NUMERIC_PRECISION
,DATETIME_PRECISION
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'TABLE_NAME'
@AllanLRH
AllanLRH / scientific_python_imports.py
Last active January 8, 2020 09:39
Scientific Python Imports
import pandas as pd
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
@AllanLRH
AllanLRH / resample_and_split_data.py
Created January 6, 2020 10:16
#resample #train_test_split
import imblearn
from sklearn import model_selection
rus = imblearn.under_sampling.RandomUnderSampler(sampling_strategy=1.0, random_state=42)
X, y = rus.fit_sample(df.drop('Target', axis=1), df.Target)
X_train, X_test, y_train, y_test = model_selection.train_test_split(X, y, test_size=0.33, random_state=42)
@AllanLRH
AllanLRH / loguru_snippet.py
Created November 27, 2019 10:59
loguru_snippet.py #python #loguru #logging
from loguru import logger
LOGGING_PATH = 'logs'
STARTED_TIME_STR = datetime.datetime.now().strftime("%m_%d_%Y__%H_%M_%S")
logger.remove()
logger.add(f"{LOGGING_PATH}/model_{STARTED_TIME_STR}.log", level='DEBUG') # Save DEBUG level to a file
logger.add(sys.stdout, level='INFO') # Print INFO level to stdout
@AllanLRH
AllanLRH / st_tips.md
Last active September 21, 2017 12:49
Christian Sublime Text tips

Hej Christian

Lige et par tips om Sublime Text, siden du er begyndt at bruge den mere :)

Sublime Text (ST) har en pakkemanager. Den hedder Package Control, og kan i nyeste udgave af ST installeres fra Command Palette (ctrl+shift+p) ved at vælge "Install package control". Du kan finde pakker og beskriveser på https://packgecontrol.io.

Jeg vil plejer at dele pakker op i domænespecifikke pakker, fx en linter til Python, og generelle pakker, fx noget som gør navigation i teksten nemmere. Her er de pakker som jeg er gladest for...