Skip to content

Instantly share code, notes, and snippets.

View lvthillo's full-sized avatar

Lorenz Vanthillo lvthillo

View GitHub Profile
@lvthillo
lvthillo / deployment.yaml
Created August 20, 2018 20:43
Example of NodePort service in Kubernetes
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
selector:
matchLabels:
run: my-app
replicas: 2
template:
@lvthillo
lvthillo / mavenPipeline.groovy
Created March 19, 2018 17:39
Reusable declarative Jenkins pipeline for maven projects
def call(body) {
def rtMaven = ''
def buildInfo = ''
def server = ''
// evaluate the body block, and collect configuration into the object
def pipelineParams= [:]
body.resolveStrategy = Closure.DELEGATE_FIRST
body.delegate = pipelineParams
body()
@lvthillo
lvthillo / docker-compose.yaml
Created March 20, 2018 18:56
docker-compose.yaml to deploy a MySQL Docker container
services:
mysql:
image: mysql:5.7
container_name: mysql
volumes:
- mysql-volume:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: db
MYSQL_USER: blog-user
@lvthillo
lvthillo / pipeline.groovy
Last active April 27, 2022 14:25
Scripted Jenkins pipeline which uses Kubernetes plugin
podTemplate(label: 'mypod', containers: [
containerTemplate(name: 'git', image: 'alpine/git', ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine', command: 'cat', ttyEnabled: true),
containerTemplate(name: 'docker', image: 'docker', command: 'cat', ttyEnabled: true)
],
volumes: [
hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'),
]
) {
node('mypod') {
@lvthillo
lvthillo / slackNotifier.groovy
Created April 11, 2018 20:30
Groovy script to send Slack Notifications
#!/usr/bin/env groovy
def call(String buildResult) {
if ( buildResult == "SUCCESS" ) {
slackSend color: "good", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} was successful"
}
else if( buildResult == "FAILURE" ) {
slackSend color: "danger", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} was failed"
}
else if( buildResult == "UNSTABLE" ) {

Keybase proof

I hereby claim:

To claim this, I am signing this object:

# stock_data contains historical data of ETH/BTC with a period of 1 hhour
# the volume is calculated by using historical data
# run this as close to each 1h interval (e.g. 7.59h or 9.59m)
last_items = stock_data.tail(24)
print(last_items)
day_volume_self_calculated = last_items['volume'].sum()
print(day_volume_self_calculated)
# better way to do it
ticker = exchange.fetch_ticker(coin_pair)
@lvthillo
lvthillo / macd.py
Last active January 12, 2021 18:23
signal = stock_data['macds'] # Your signal line
macd = stock_data['macd'] # The MACD that need to cross the signal line
advice = ["No data"] # Since you need at least two hours in the for loop
for i in range(1, len(signal)):
# If the MACD crosses the signal line upward
if macd[i] > signal[i] and macd[i - 1] <= signal[i - 1]:
advice.append("BUY")
# The other way around
elif macd[i] < signal[i] and macd[i - 1] >= signal[i - 1]:
@lvthillo
lvthillo / ohlcv.py
Last active January 12, 2021 18:18
import ccxt
import os
import re
import time
import pandas as pd
from stockstats import StockDataFrame as Sdf
def get_historical_data(coin_pair, timeframe):
"""Get Historical data (ohlcv) from a coin_pair
import ccxt
import os
import re
# configure exchange
exchange = getattr(ccxt, 'binance')({
'apiKey': os.environ['APIKEY'],
'secret': os.environ['SECRET'],
'timeout': 10000,
'enableRateLimit': True