Skip to content

Instantly share code, notes, and snippets.

View casperlehmann's full-sized avatar

Casper Lehmann casperlehmann

View GitHub Profile
16:9
vs Dell P2715Q (Egmont) 27" 100% 16:9 (100:100) | 59x33cm 100x 100% | 2009cm2 100% | 3840x2160px 100x100% | 3600kr (100%) :: Display port | 100%
vs Macbook Dashou 13" 48% 16:9 (100:100) | 28x16cm 48x 48% | 465cm2 23% | 2560x1600px 66x 74% | 12000kr (333%) :: | 48%
vs Dell P2721Q (Mauro) 27" 100% 16:9 (100:100) | 59x33cm 100x 100% | 2009cm2 100% | 3840x2160px 100x100% | 3699kr (102%) :: usb-c | 100%
21:9
vs Samsung C34H890WG 34" 125% 21:9 (131:100) | 79x34cm 132x 101% | 2700cm2 134% | 3440x1440px 89x 66% | 4190kr (116%) :: usb-c | 132%
vs Samsung C34J791 34" 125% 21:9 (131:100) | 79x34cm 132x 101% | 2700cm2 134% | 3440x1440px 89x 66% | 5799kr (161%) :: DP/HDMI/USB-C | 132%
vs Samsung C34G55T 34" 125% 21:9 (131:100) | 79x34cm 132x 101% | 2700cm2 134% | 3440x1440px 89x 66% | 3999kr (111%) :: HDMI/DP | 132%
vs Samsung C34J791WTU 34" 125% 21:9 (131:1
@casperlehmann
casperlehmann / bug_report.sql
Last active January 12, 2021 19:25
Synapse Studio throughput issue
-- Querying Delta Lake, 643715 rows
-- Created, optimized and vacuumed with Databricks
-- Partitioned by year and month (filepath 1 and 2)
-- Spark parquet repartition(1) means 1 file per partition
-- Runtime:
-- SSMS: 01:31
-- Synapse Workspace top 5000 rows: 03:15
-- Synapse Workspace all rows: 25:29
-- Hard-coding the partition names makes no discernible difference
@casperlehmann
casperlehmann / git-deployment.md
Created August 24, 2020 20:29 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

DROP EXTERNAL TABLE tests_external_table
DROP EXTERNAL FILE FORMAT file_format_name
DROP EXTERNAL DATA SOURCE extdatasource;
DROP DATABASE SCOPED CREDENTIAL ADLSCredential;
CREATE DATABASE SCOPED CREDENTIAL ADLSCredential
WITH IDENTITY = 'User Identity',
SECRET = '...............=='
from time import sleep
def count_sheep():
for _ in range(100):
sleep(.01)
yield _
def load_screen(factor = 3):
for counter in count_sheep():
bar = ''.join(['#' if _ < counter/factor else ' ' for _ in range(100//factor)])
@casperlehmann
casperlehmann / weirdness.py
Created October 17, 2019 20:41
I feel like this shouldn't be allowed
# weirdness.py
def loop_for(i, li=[]):
while len(li) <= i:
print(li)
li[len(li):len(li)+1] = [len(li)]
loop_for(9)
loop_for(9, ['x', 'y', 'z'])
"""
@casperlehmann
casperlehmann / win-env-var-setter.py
Last active August 23, 2019 13:12
Class for setting, changing and deleting environment variables in Windows Registry
# python
# Borrowing heavily from: https://stackoverflow.com/a/35286642
import winreg
class RegHandler:
def __init__(self, reg_path: str):
self.reg_path = reg_path
def set_reg(self, name, value):
try:
TOKEN = 'XXX'
REPORT_ID = 'YYY'
GROUP_ID = 'ZZZ'
delete_url = f'https://api.powerbi.com/v1.0/myorg/groups/{GROUP_ID}/reports/{REPORT_ID}'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + TOKEN
}
res = requests.post(delete_url, headers=headers)
@casperlehmann
casperlehmann / power_bi_report_change_dataset.py
Created January 25, 2019 11:31
Script to change dataset for a Power BI report
import requests
import adal
import json
# Parameters:
GROUP_ID = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
# AAD Client ID -- To get this, go here: https://dev.powerbi.com/apps
CLIENT_ID = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
AUTHENTICATION_URL = 'https://login.microsoftonline.com/egmont.onmicrosoft.com'
#! -*- coding:utf8 -*-
def generate_inverse_transformations(left,right):
return (
lambda left: {
'uuid': left.get('key'),
'first_name': left.get('name').get('first'),
'last_name': left.get('name').get('last'),
'triple_tuples': [x for x in left.get('triples').items()],
'opposites': [{'first': x, 'second': y} for x,y in left.get('opposites')]