Skip to content

Instantly share code, notes, and snippets.

View mysticaltech's full-sized avatar

K. N. mysticaltech

View GitHub Profile
@mysticaltech
mysticaltech / dunn.py
Created May 8, 2020 10:05 — forked from alimuldal/dunn.py
Implementation of Dunn's multiple comparison test, following a Kruskal-Wallis 1-way ANOVA
import numpy as np
from scipy import stats
from itertools import combinations
from statsmodels.stats.multitest import multipletests
from statsmodels.stats.libqsturng import psturng
import warnings
def kw_dunn(groups, to_compare=None, alpha=0.05, method='bonf'):
"""
@mysticaltech
mysticaltech / simulatePOWERdistributions
Created June 24, 2020 10:29 — forked from Lakens/simulatePOWERdistributions
Simulate Power Distributions
library(MBESS)
library(pwr)
nSims <- 100000 #number of simulated experiments
p <-numeric(nSims) #set up empty container for all simulated p-values
obs_pwr <-numeric(nSims) #set up empty container
t <-numeric(nSims) #set up empty container
d_all<-numeric(nSims)
N<-33 #number of participants
@mysticaltech
mysticaltech / bitbucket-webhook.php
Created August 22, 2020 23:25
A simple php script for deploy using bitbucket webhook
<?php
// edit these lines:
// example: /var/www/repositories/project.git
$repo_dir = '~/repository.git';
// example: /var/www/project
$web_root_dir = '~/project';
// example: /var/www/project/scripts/post_deploy.sh
@mysticaltech
mysticaltech / html_to_text.py
Created July 29, 2021 09:43 — forked from racitup/html_to_text.py
Extract text from html in python using BeautifulSoup4
from bs4 import BeautifulSoup, NavigableString, Tag
def html_to_text(html):
"Creates a formatted text email message as a string from a rendered html template (page)"
soup = BeautifulSoup(html, 'html.parser')
# Ignore anything in head
body, text = soup.body, []
for element in body.descendants:
# We use type and not isinstance since comments, cdata, etc are subclasses that we don't want
if type(element) == NavigableString:
@mysticaltech
mysticaltech / crc.py
Created October 11, 2021 16:53 — forked from Lauszus/crc.py
Generic CRC-8, CRC-16 and CRC-32 calculations in Python
#!/usr/bin/env python
# Inspired by: https://www.youtube.com/watch?v=izG7qT0EpBw
# The CRC values are verified using: https://crccalc.com/
def reflect_data(x, width):
# See: https://stackoverflow.com/a/20918545
if width == 8:
x = ((x & 0x55) << 1) | ((x & 0xAA) >> 1)
x = ((x & 0x33) << 2) | ((x & 0xCC) >> 2)
x = ((x & 0x0F) << 4) | ((x & 0xF0) >> 4)
@mysticaltech
mysticaltech / bayesian_ab_test.py
Created November 29, 2021 11:07 — forked from stucchio/bayesian_ab_test.py
Bayesian A/B test code
from matplotlib import use
from pylab import *
from scipy.stats import beta, norm, uniform
from random import random
from numpy import *
import numpy as np
import os
# Input data
@mysticaltech
mysticaltech / mirror_mirror.sh
Created December 3, 2021 20:35 — forked from marshki/mirror_mirror.sh
One-way Rsync mirror of data from source to destination. Run as a crontab.
#!/usr/bin/env bash
#
# mirror_mirror
#
# One-way Rsync mirror of data from source to destination.
#
# Author: M. Krinitz <mjk235 [at] nyu [dot] edu>
# Date: 2020.04.20
# License: MIT
#
@mysticaltech
mysticaltech / gist:b66e9a5d7e25d0ef9c3afeb1650c30c9
Created October 26, 2022 23:50 — forked from koakh/gist:fbbc37cde630bedcf57acfd4d6a6956b
SurrealDB : How to use signin and signup (server + client nodesjs)
**As a developer you have complete control over the signup and signin functionality...**
```shell
$ surreal sql --conn http://localhost:8000 --user root --pass root --ns test --db test
```
```sql
-- optional : this is the default see --ns test --db test start server flags
-- USE NS test DB test;
@mysticaltech
mysticaltech / rage-clicks.js
Created December 1, 2022 16:38 — forked from silversillu/rage-clicks.js
Tracking Rage Clicks using GTM
if ( typeof(jQuery) === 'function' ) {
jQuery(document).ready(function($) {
jQuery.fn.extend({
getPath: function() {
var path, node = this;
while (node.length) {
var realNode = node[0],
name = realNode.localName;
if (!name) break;
name = name.toLowerCase();
@mysticaltech
mysticaltech / 01_longhorn_bestpractices.md
Created December 2, 2022 22:58 — forked from ifeulner/01_longhorn_bestpractices.md
Longhorn hcloud best practices

Longhorn best practices

The following settings are provided as an example how longhorn should be configured in a production cluster, especially if it is deployed on Hetzner Cloud infrastructure.

Hetzner server nodes provide local storage and allow up to five attached volumes (with a size of up to 10TiB each) Local storage is provided by NVMe storage and therefore is much faster than the attached volumes, but limited in size (max 300GiB usable).

Initial configuration

Also you want to control the nodes that are used for storage. So it is suggested to set the option Create default disk only on labeled node to true