Skip to content

Instantly share code, notes, and snippets.

View mysticaltech's full-sized avatar

K. N. mysticaltech

  • Spain
View GitHub Profile
@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 / bitbucket-webhook.php
Created August 22, 2020 23:25 — forked from jarnix/bitbucket-webhook.php
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 / 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 / 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'):
"""
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mysticaltech
mysticaltech / sample_size_AB.R
Created April 3, 2020 08:22 — forked from uttara-cmu/sample_size_AB.R
Evan Miller's Tool - R code
# The code given in #2 gist is not in R. There is a change in formula compared to the one in this blog post and the one used by Evan Miller's tool (#3). http://www.alfredo.motta.name/ab-testing-from-scratch/#easy-footnote-bottom-24-982
#1. https://stats.stackexchange.com/questions/357336/create-an-a-b-sample-size-calculator-using-evan-millers-post
#2. https://gist.github.com/mottalrd/7ddfd45d14bc7433dec2#file-gistfile1-txt
#3. https://www.evanmiller.org/ab-testing/sample-size.html
p = 0.03
pct_mde = 0.1
alpha = 0.05
power = 1- 0.2
@mysticaltech
mysticaltech / make_audiobook.py
Created April 2, 2020 11:10 — forked from madebyollin/make_audiobook.py
Converts an epub or text file to audiobook via Google Cloud TTS
#!/usr/bin/env python3
"""
To use:
1. install/set-up the google cloud api and dependencies listed on https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/texttospeech/cloud-client
2. install pandoc and pypandoc, also tqdm
3. create and download a service_account.json ("Service account key") from https://console.cloud.google.com/apis/credentials
4. run GOOGLE_APPLICATION_CREDENTIALS=service_account.json python make_audiobook.py book_name.epub
"""
import re
import sys
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@mysticaltech
mysticaltech / pi3_browser-only.md
Created April 8, 2019 23:55 — forked from bheisig/pi3_browser-only.md
Run Raspberry 3 in digital signage mode with Chromium Web browser on a TV screen
@mysticaltech
mysticaltech / tvncserver
Created October 3, 2018 18:19
/etc/rc.d/init.d/ file to add TurboVNC as a service on centos
#!/bin/bash
#
# chkconfig: - 91 35
# description: Starts and stops the TurboVNC Server
#
### If you are using LDAP or another distributed authentication system, then
### be sure to add any services needed for your distributed authentication
### system to the Required-Start line below.
#
### BEGIN INIT INFO