Skip to content

Instantly share code, notes, and snippets.

View fty4's full-sized avatar
⛰️

Marco Lecheler fty4

⛰️
View GitHub Profile
@fty4
fty4 / insert-in-slice.go
Created October 8, 2019 13:21
adds a value to a string-slice after a specific position
package main
import (
"fmt"
)
func main() {
var a,b []string
a = []string{"a","b","d","e"}
docker run --rm --volume ${PWD}:/opt -it alpine /bin/sh
# in container
#export HTTPS_PROXY=http://10.0.4.1:3128/
#export HTTP_PROXY=http://10.0.4.1:3128/
cd /opt
apk add git make gcc libc-dev
git clone https://github.com/apangin/jattach.git && cd jattach/
make all
@fty4
fty4 / generate-mosquitto-pw.sh
Created March 25, 2019 19:42
Generates passwordfile for mosquitto mqtt broker
#!/bin/bash
if [ $# -ne 2 ]; then
echo "USAGE: <username> <password>"
exit 1
fi
docker run -it eclipse-mosquitto /bin/sh -c "touch tmppwsave && mosquitto_passwd -b tmppwsave ${1} ${2} && cat tmppwsave && rm tmppwsave"
@fty4
fty4 / pireader.sh
Created March 17, 2019 00:38
reads out pi from google pi.delivery API
#!/bin/sh
min=0
step=1000
file=output.txt
while true
do
curl -s https://api.pi.delivery/v1/pi\?start\=$min\&numberOfDigits\=$step | jq --join-output '.content' >> $file
min=$(($min + $step))
// prime factorization for n
func getPrimeFactorization(n int) ([]int) {
var primefactors []int
// check divisibility by 2,3 and all odd numbers up to n
var divider = append([]int{2}, getOddNumbers(n)...)
for _, i := range divider {
for n % i == 0 {
primefactors = append(primefactors, i)
n = n / i
@fty4
fty4 / delete_all_jira_comments.py
Created June 19, 2018 10:46
This script removes all comments from a specified jira issue
'''
This script removes all comments from a specified jira issue
Please provide Jira-Issue-Key/Id, Jira-URL, Username, PAssword in the variables below.
'''
import sys
import json
import requests
import urllib3
@fty4
fty4 / objectdump.py
Created May 30, 2018 05:51
dump python object to console
def dump(obj):
for attr in dir(obj):
print("obj.%s = %r" % (attr, getattr(obj, attr)))
@fty4
fty4 / customHearders.php
Created January 8, 2018 12:15
custom headers (name, description) for ics
$customHeaders = [
"X-WR-CALNAME" => "foo",
"X-WR-CALDESC" => "bar",
];
$cal->setCustomHeaders($customHeaders);
@fty4
fty4 / googol.java
Created August 29, 2017 08:23
googol as BigInteger
import java.math.BigInteger;
public class googol {
public static void main(String[] args) {
BigInteger bi = BigInteger.valueOf(10);
bi = bi.pow(100);
System.out.println(bi.toString());
}
@fty4
fty4 / HelloJob.java
Created May 22, 2017 11:06
Run Task every x seconds / minutes / hours
package tst;
import java.util.ArrayList;
import java.util.List;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;