Skip to content

Instantly share code, notes, and snippets.

View UplandsDynamic's full-sized avatar
🏠
Working from home

Dan Bright UplandsDynamic

🏠
Working from home
View GitHub Profile
@UplandsDynamic
UplandsDynamic / root-password-MariaDB-docker-compose.md
Created July 18, 2022 19:13 — forked from rordi/root-password-MariaDB-docker-compose.md
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
@UplandsDynamic
UplandsDynamic / install-opencv-mbp-m1
Last active February 21, 2022 16:29
Install OpenCV for C++ on MacBook Pro M1 (2020)
Here are the steps required to install OpenCV for C++ on the MacBook Pro M1.
1. If not already installed, install Homebrew, by following instructions here: https://brew.sh/.
2. If Xcode is not already installed, install it from the App Store (or other methods).
3. Open a terminal and run:
brew install opencv
4. In the terminal, run:
@UplandsDynamic
UplandsDynamic / scrollToAnchorExample.ts
Last active August 23, 2017 10:15
How to scroll to a fragment in Angular.io (scroll to anchor)
import { Component, OnInit } from '@angular/core';
import { OnDestroy } from '@angular/core';
import { Router, NavigationEnd } from '@angular/router';
import { Subscription } from 'rxjs/Rx';
@Component({
selector: 'scroll-to-anchor-example',
template: `<a type="button" md-button class="button" routerLink="/this-view-url"
fragment="test-fragment" routerLinkActive="active">Go to test fragment</a>
<p>Blah blah blah ...</p>
@UplandsDynamic
UplandsDynamic / gist:8210e210f3cfab0200450db5a91c5ccc
Created August 3, 2017 11:16
Javascript (Typescript): Remove empty properties from object
deleteEmptyProps(obj: any): any {
// modifies passed obj in place, removing empty properties (inc. empty arrays)
return Object.keys(obj).forEach(k => {
if (!obj[k] || obj[k] === undefined ||
Array.isArray(obj[k]) && obj[k].length === 0) {
delete obj[k];
}
});
}
@UplandsDynamic
UplandsDynamic / gist:ae77c1832205c6208703653a5b8502f2
Created July 31, 2017 23:08
brave.browser-laptop.2017-07-31T22_57_38_988Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/home/dan/.nvm/versions/node/v7.9.0/bin/node',
1 verbose cli '/home/dan/.nvm/versions/node/v7.9.0/bin/npm',
1 verbose cli 'run',
1 verbose cli 'build-installer' ]
2 info using npm@4.2.0
3 info using node@v7.9.0
4 verbose run-script [ 'prebuild-installer',
4 verbose run-script 'build-installer',
4 verbose run-script 'postbuild-installer' ]
@UplandsDynamic
UplandsDynamic / gist:d141ed6627b9fc8688d701ff9efd4bd3
Created May 16, 2017 00:49
Javascript performance tests: Remove elements from array
let o1 = performance.now();
let test = ['a', 'b', 'c']
let toRemove = test.indexOf('b');
if(toRemove !== -1){
test.splice(toRemove, 1)
console.log(test);
}
let o2 = performance.now();
console.log(o2 - o1);
@UplandsDynamic
UplandsDynamic / django_url_param_updater.py
Created October 18, 2016 22:22
Function for Python Django to update request.GET parameters, retaining all existing parameters, with a given parameter added or updated.
def update_url_param(request, param_name):
# function to update request.GET params, retaining all existing params, with param_name added or updated.
existing_params = dict(request.GET) # convert immutable querydict to mutable dict
if not existing_params:
return '?{}='.format(param_name)
else: # if existing params
existing_str = ''
existing_params.pop(param_name, None) # pop off existing param_name if exists
for p, v in existing_params.items():
existing_str += '{}{}&'.format(p, '={}'.format(v[0]) if v[0] else '')