Skip to content

Instantly share code, notes, and snippets.

View Addvilz's full-sized avatar

Matīss Addvilz

View GitHub Profile
@Addvilz
Addvilz / tcptunnel.java
Created June 25, 2017 15:29 — forked from ilmich/tcptunnel.java
Java NIO tcp tunnel
package ctptunnel;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.HashMap;
@Addvilz
Addvilz / Makefile
Last active July 28, 2021 16:15
Makefile help snipped
# Lines prefixed with [hash]- are header lines
# Targets can have tailing [hash]: to document functions
# Target groups can have preceding lines [hash]? name: description to document target groups
help: #: Show this help
@fgrep -h "#-" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/#-\s//'
@printf "\n"
@printf "Common targets:\n"
@fgrep -h "#+" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -Ee "s/([^:]+)(.*)(#\+(.*))/- \1:\4/g"
### Keybase proof
I hereby claim:
* I am addvilz on github.
* I am addvilz (https://keybase.io/addvilz) on keybase.
* I have a public key whose fingerprint is 3B44 AE79 519B 1C65 5294 1B10 9123 B913 EBF5 3D43
To claim this, I am signing this object:
@Addvilz
Addvilz / gist:438dd29c50222eca1b20186a79c15154
Created September 9, 2019 09:01 — forked from joachimkainz/gist:1357460
kill all queries in mongo
db.currentOP().inprog.forEach(function(v){if (v.op == "query") { db.killOP(v.opid);}});
# Download tar.gz and then update-alternatives --config java and choose appropriate slot.
update-alternatives --install /usr/bin/java java /opt/openjdk/openjdk-11-ea+9_linux-x64_bin/jdk-11/bin/java SLOT
update-alternatives --config java
# Also gradle
update-alternatives --install /usr/bin/gradle gradle /opt/gradle/gradle-4.6/ 1
# Also maven
update-alternatives --install /usr/bin/mvn mvn /opt/maven/apache-maven-3.5.3/bin/mvn 1
049c1f07bc1d46f791498cfe63f54bc75224375226e9e47eb59eabb444c2c6f9ab76efdc3c20ba7055538dbf1fda702e0e486cba741273c94154374f334d8f0796
@Addvilz
Addvilz / gist:5f7604224ce0238af7fd
Created March 6, 2015 14:08
phpstorm setter with self reference and correct type hints
## Editor>File and Code Templates>Code>PHP Setter Method
#set($typeHintText = "$TYPE_HINT ")
## First we check against a blacklist of primitive and other common types used in documentation.
#set($nonTypeHintableTypes = ["", "string", "int", "mixed", "number", "void", "object", "real", "double", "float", "resource", "null", "bool", "boolean"])
#foreach($nonTypeHintableType in $nonTypeHintableTypes)
#if ($nonTypeHintableType == $TYPE_HINT)
#set($typeHintText = "")
#end
#end
## Make sure the type hint actually looks like a legal php class name(permitting namespaces too) for future proofing reasons.
@Addvilz
Addvilz / holtwinters.py
Created September 6, 2017 16:53 — forked from andrequeiroz/holtwinters.py
Implementation of Holt-Winters algorithms in Python 2
#The MIT License (MIT)
#
#Copyright (c) 2015 Andre Queiroz
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
The initial MVP did not have the timetracker and users had to create their own invoices. This proved to be the biggest
problem freelancers wanted solved, so a timetracker was implemeneted.
Users noticed that the timetracker would not persist if the browser was closed. Users requested a persistent timetracker, that would not
stop until the user clicks "stop"
@Addvilz
Addvilz / gist:3e566f5a1a5cb769b4ad
Last active August 30, 2016 12:47
php-cs-precommit
#!/usr/bin/php
<?php
function progress($i, $total, $label = null, $end=null){
$percent = ceil(($i / $total) * 100);
$barSize = ceil($percent/2);
$blankSize = 50 - $barSize;
if(($blankSize + $barSize) < 50){
$blankSize += (50 - ($blankSize + $barSize));
}