Skip to content

Instantly share code, notes, and snippets.

@gerard-kanters
gerard-kanters / inactivity.js
Last active March 6, 2024 18:49
Inactivity timeout javascript
<script type="text/javascript">
function idleTimer() {
var t;
//window.onload = resetTimer;
window.onmousemove = resetTimer; // catches mouse movements
window.onmousedown = resetTimer; // catches mouse movements
window.onclick = resetTimer; // catches mouse clicks
window.onscroll = resetTimer; // catches scrolling
window.onkeypress = resetTimer; //catches keyboard actions
@pennycoders
pennycoders / mariadb-recovery.sh
Created January 30, 2018 21:58
kolla-ansible galera recovery script
#!/usr/bin/env bash
inventory_file=${1:-'/provisioning/kolla/multinode.ini'}
hosts=${2:-'control1,compute1,compute2'}
ansible -i ${inventory_file} -a 'docker stop mariadb' ${hosts}
ansible -i ${inventory_file} -a 'cat /var/lib/docker/volumes/mariadb/_data/grastate.dat' ${hosts}
@m-root
m-root / vsa.py
Last active December 27, 2022 14:11
Volume Spread Analysis
import talib
import statsmodels.api as sm
import pandas as pd
def initialize(context):
context.security = symbol('AAPL')
#set_universe(universe.DollarVolumeUniverse(floor_percentile=98.0,ceiling_percentile=100.0))
def bar_data(OHLC_type, bars_nr):
bar_data_func = (history((bars_nr + 1), '1d', OHLC_type).iloc[0]).astype('float')
@Tras2
Tras2 / cloudflare-ddns-update.sh
Last active July 7, 2024 01:28
A bash script to update a Cloudflare DNS A record with the external IP of the source machine
#!/bin/bash
# A bash script to update a Cloudflare DNS A record with the external IP of the source machine
# Used to provide DDNS service for my home
# Needs the DNS record pre-creating on Cloudflare
# Proxy - uncomment and provide details if using a proxy
#export https_proxy=http://<proxyuser>:<proxypassword>@<proxyip>:<proxyport>
# Cloudflare zone is the zone which holds the record
@18182324
18182324 / Pairs Trading Strategy Backtest for copula method [Python Code]
Last active February 7, 2023 02:57
Pairs Trading Strategy Backtest for copula method [Python Code]
import numpy as np
from scipy import stats
from statsmodels.distributions.empirical_distribution import ECDF
from scipy.stats import kendalltau, pearsonr, spearmanr
from scipy.optimize import minimize
from scipy.integrate import quad
import sys
from collections import deque
@Component({
template: `
<h1 [style.--color]="color">CSS vars works!</h1>
`,
styles: [
`
h1 {
color: var(--color);
}
`
@18182324
18182324 / pairs-trading-advanced-strategy
Created November 14, 2021 10:01
Pairs Trading Advanced K-Means Algorithm Clustering
companies_dict = {
'Amazon':'AMZN',
'Apple':'AAPL',
'Walgreen':'WBA',
'Northrop Grumman':'NOC',
'Boeing':'BA',
'Lockheed Martin':'LMT',
'McDonalds':'MCD',
'Intel':'INTC',
'Navistar':'NAV',
@jooosh
jooosh / cloudflare_ddns_update.sh
Last active January 30, 2024 02:38 — forked from Tras2/cloudflare-ddns-update.sh
A bash script to update a Cloudflare DNS A record with the external IP of the source machine
# A bash script to update a Cloudflare DNS A record with the external IP of the source machine
# Used to provide DDNS service for my home
# Needs the DNS record pre-creating on Cloudflare
# Proxy - uncomment and provide details if using a proxy
#export https_proxy=http://<proxyuser>:<proxypassword>@<proxyip>:<proxyport>
# Cloudflare zone is the zone which holds the record
zone=example.com
# dnsrecord is the A record which will be updated
@maheshj01
maheshj01 / bottomnavbar.dart
Last active September 2, 2023 11:53
Demo app for a medium post "Everything about the Nested bottom navigation bar"
/*
* File: main.dart
* Project: BottomNavigationBar demo
* File Created: Wednesday, 26th May 2022 1:15:47 pm
* Author: Mahesh Jamdade
* -----
* Last Modified: Saturday, 28th May 2022 4:42:07 pm
* Modified By: Mahesh Jamdade
* -----
*/
@larsks
larsks / boot.sh
Created September 6, 2022 02:24
Booting raspberry pi 64 bit using qemu
#!/bin/sh
SERIAL1=( -chardev stdio,id=uart1 -serial chardev:uart1 -monitor none )
SERIAL2=( -serial vc -serial vc )
SERIAL3=( -nographic -serial mon:stdio )
EMU_RASPI=( -M raspi3 )
EMU_VIRT=( -M virt -cpu cortex-a72 )
NET_TAP=(