Skip to content

Instantly share code, notes, and snippets.

View anton-dzodzikov's full-sized avatar

Anton Dzodzikov anton-dzodzikov

View GitHub Profile
@anton-dzodzikov
anton-dzodzikov / gist:0968a22d3a36e573afb2d3cdb66203ca
Last active September 10, 2019 12:26 — forked from psayre23/gist:c30a821239f4818b0709
Runtime Complexity of Java Collections
Below are the Big O performance of common functions of different Java Collections.
List | Add | Remove | Get | Contains | Next | Data Structure
---------------------|------|--------|------|----------|------|---------------
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array
LinkedList | O(1) | O(1) amortized | O(n) | O(n) | O(1) | Linked List
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:9000;
proxy_redirect http://localhost:9000 http://dzodzikov.com;
}
location /portainer/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:9000/;
proxy_redirect http://localhost:9000/ http://dzodzikov.com/portainer/;
}
/**
* Runs remote Jenkins job and waits for it to finish
*
* Use in Gitlab CI YAML as follows:
* mvn -q groovy:execute -Dsource=ci/execute-remote-job.groovy -Durl=URL -DjobName=NAME -Dlogin=LOGIN -Dpassword=PASS -Dparameters.one=ONE -Dparameters.two=TWO
*
* Expects as input:
* url - URL of Jenkins
* jobName - name of the job
* login - login of the user of Jenkins
def factorial(number: Int): Int = {
def factorialIter(multiple: Int, nextNumber: Int): Int = {
if (nextNumber == 1) multiple else factorialIter(multiple * nextNumber, nextNumber - 1)
}
factorialIter(number, number - 1)
}
@anton-dzodzikov
anton-dzodzikov / tomcat manager deploy
Created October 3, 2017 03:41 — forked from pete911/tomcat manager deploy
tomcat - deploy war files using curl
# deploy under "path" context path
curl --upload-file appplication-0.1-1.war "http://tomcat:tomcat@localhost:8080/manager/deploy?path=/application-0.1-1
# undeploy
curl "http://tomcat:tomcat@localhost:8080/manager/undeploy?path=/application-0.1-1"
# ! tomcat7 uses /manager/text/undeploy and /manager/text/deploy paths
# tomcat6-admin (debian) or tomcat6-admin-webapps (rhel) has to be installed
# tomcat-users.xml has to be setup with user that has admin, manager and manager-script roles
def send_request(url, data, method, content_type):
"""
Send HTTP request and return response
"""
opener = urllib2.build_opener(urllib2.HTTPHandler)
request = urllib2.Request(url, data=data)
request.add_header('Content-Type', content_type)
request.get_method = lambda: method