Skip to content

Instantly share code, notes, and snippets.

View rordi's full-sized avatar
🎓

Dietrich Rordorf rordi

🎓
View GitHub Profile

Tensorflow & Keras in RStudio on Apple M1 or M2 (arm64) Chips

The problem is not M1 or M2 (arm64) chipset. The problem is keras installation that installs tensorflow-metal, which makes Keras to choose GPU over CPU, even if Sys.setenv("CUDA_VISIBLE_DEVICES" = -1) is set. However, Apple's GPUs are not supported yet by tensorflow-metal. Thus, we have to get rid of tensorflow-metal! Combined with R / RStudio, the trick is to use a dedicated r-reticulate environment to run python and to manually uninstall tensorflow-metal again, which is installed automatically whenever we install and load the keras package in R.

Install Anaconda for arm64 first: https://docs.anaconda.com/anaconda/install/mac-os/

@rordi
rordi / git-commit.md
Last active September 16, 2020 07:40
Commands to get basic info about a git commit

Commands to get basic info about a git commit

  • Deploy Timestamp: date +"%Y-%m-%d %H:%M:%S"
  • Git Repo: basename `git rev-parse --show-toplevel`
  • Git Branch: git rev-parse --abbrev-ref HEAD
  • Git Commit Long Hash: git rev-parse HEAD
  • Git Commit Short Hash: git rev-parse --short HEAD
@rordi
rordi / config.user.inc.php
Last active June 23, 2021 15:59
Configuration hardening for PhpMyAdmin
<?php
/**
* Configuration hardening for PhpMyAdmin
*
* This file is included at the end of the main PhpMyAdmin configuration file. We thus here override
* any potential config value that was previously set.
*
* @author Dietrich Rordorf
* @date 2018-11-05
* @see https://docs.phpmyadmin.net/en/latest/config.html
@rordi
rordi / root-password-MariaDB-docker-compose.md
Last active January 23, 2024 15:36
Change root password in MariaDB Docker container running with docker-compose

Change root password in MariaDB Docker container running with docker-compose

Override the entrypoint in docker-compose.yml for the MariaDB Docker container by adding:

entrypoint: mysqld_safe --skip-grant-tables --user=mysql

The start up the Docker Compose stack:

$> docker-compose up -d

MariaDB / MySQL Cheatlist

Import a dump file:

mysql -u userName --password=yourSecret dbName < ./path/to/dump.sql

Run command non-interactive:

mysql -u userName --pasword=yourSecret dbName -e 'SELECT * FROM my_table;'
@rordi
rordi / Operator-Mono-Dark-patched-didi.itermcolors
Created August 28, 2019 12:21
patched Operator Mono Dark colors for iterm
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.35364818572998047</real>
@rordi
rordi / selenium-chrome-options.js
Last active August 20, 2019 15:28
Javascript Selenium Web Driver with Chrome Options
const {Builder, By, Capabilities} = require('selenium-webdriver');
let chromeCapabilities = Capabilities.chrome();
let chromeOptions = {
'args': ['--test-type', '--headles', '--incognito', '--window-size=340,750'] // approx. size of an iPhone 5/SE
};
// "chromeOptions" was changed to "goog:chromeOptions" at some point...
chromeCapabilities.set('goog:chromeOptions', chromeOptions);
@rordi
rordi / hugo-prev-next-navigation-custom-section.order.md
Last active April 18, 2021 18:33
Previous / Next Navigation in Hugo with custom section order

Previous/Next navigation in Hugo with custom order based on param / attribute

This gist let's you return previous/next pages based on a frontmatter parameter in Hugo. In this exmaple, the frontmatter parameter is called position, where lower positions come first.

This prev / next navigation is looping: if there is no "next >" entry anymore, the first entry of the collection will be linked. Same for "< prev": if there is no previous element, the last element of the collection will be linked.

<div class="nav-prev-next">
    {{ $currentSection := (($.Site.GetPage "section" .Section).Pages.ByParam "position") }}
@rordi
rordi / wordpress-proxy.md
Last active September 16, 2021 11:52
Run Wordpress behind a proxy server (avoid assets being blocked)

Run Wordpress behind a proxy server (avoid assets being blocked)

Wordpress has issues to detect the SSL connection betwenn the client and the proxy and thus may load static assets through http instead https, which will be blocked in moderns browsers (mixed content).

To circumvent the problem, simly extend your wp-config.php by following functions (insert towards the top of the config script):

/** Proxy SSL detection */

Remove a large file from previous git commit / GitHub

E.g. when accidentally committing a large file to a git repo and GitHub refises the commit.

git filter-branch --tree-filter 'rm -f path/to/large/file' HEAD

Afterwards, simply try to push to GitHub again...