Skip to content

Instantly share code, notes, and snippets.

View niklasravnsborg's full-sized avatar
🇺🇦
#StandWithUkraine

Niklas Ravnsborg niklasravnsborg

🇺🇦
#StandWithUkraine
View GitHub Profile
@niklasravnsborg
niklasravnsborg / convert.py
Created May 17, 2023 16:47
DICOM to JPG with Python
# Influenced by:
# - https://stackoverflow.com/questions/59458801/how-to-sort-dicom-slices-in-correct-order
# - https://medium.com/@vivek8981/dicom-to-jpg-and-extract-all-patients-information-using-python-5e6dd1f1a07d
import glob
import pydicom as dicom
import os
import cv2
import sys
import numpy as np
@niklasravnsborg
niklasravnsborg / wp2static_filter.php
Created January 25, 2023 16:06
WP2Static Filter
<?php
add_filter('wp2static_detect_sitemaps', function() {
return false;
});
// add_filter('wp2static_detect_parent_theme', function() {
// return false;
// });

Keybase proof

I hereby claim:

  • I am niklasravnsborg on github.
  • I am niklasravnsborg (https://keybase.io/niklasravnsborg) on keybase.
  • I have a public key ASAw2pOsBKwsVt-OU9aaR1FC3qbu8YZXvtaQSZ4DnvKpNwo

To claim this, I am signing this object:

@niklasravnsborg
niklasravnsborg / change_date_of_all.py
Created October 11, 2015 13:41
File and Image Sorting
import os, datetime, time
for dir in os.listdir('.'):
if os.path.isdir(dir):
dates = []
for file in os.listdir(dir):
if file.endswith(('.jpg', '.jpeg')):
photo = os.path.join(dir, file)
@niklasravnsborg
niklasravnsborg / render_scenes.py
Created June 28, 2015 18:42
render multiple scenes in single .blend file
import bpy
for scene in bpy.data.scenes:
print('rendering: ' + scene.name)
bpy.context.screen.scene = scene
scene.render.filepath = '//render/' + scene.name + '/' + scene.name
scene.render.resolution_percentage = 100
scene.render.image_settings.file_format = 'H264'
@niklasravnsborg
niklasravnsborg / .htaccess
Last active October 5, 2016 21:02
one.com uses subdirectories as subdomains, here is a handy rewrite
RewriteEngine On
# redirect subdomains to matching folders
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{SERVER_ADDR} !=127.0.0.1
RewriteCond %{SERVER_ADDR} !=::1
RewriteCond %{HTTP_HOST} !.*\.yourhost.com
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
@niklasravnsborg
niklasravnsborg / foundation-grid.scss
Last active October 16, 2018 10:19
Foundation Grid - without Foundation
// RANGES
// We use these functions to define ranges for various things, like media queries.
@function lower-bound($range){
@if length($range) <= 0 {
@return 0;
}
@return nth($range,1);
}
@function upper-bound($range) {
@niklasravnsborg
niklasravnsborg / easymail.php
Last active August 29, 2015 14:12 — forked from richartkeil/easymail.php
Send Mails with PHP
<?php
// USAGE
// include easymail.php `include('easymail.php');`
// Use like this `sendMail('to which mail address',
// 'message',
// 'subject',
// 'from which mail address',
// 'name to',
// 'name from');`