Skip to content

Instantly share code, notes, and snippets.

@0xh3xa
0xh3xa / vagrant-cheat-sheet.md
Created February 20, 2020 13:27 — forked from wpscholar/vagrant-cheat-sheet.md
Vagrant Cheat Sheet

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Creating a VM

  • vagrant init -- Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.
  • vagrant init <boxpath> -- Initialize Vagrant with a specific box. To find a box, go to the public Vagrant box catalog. When you find one you like, just replace it's name with boxpath. For example, vagrant init ubuntu/trusty64.

Starting a VM

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
@0xh3xa
0xh3xa / server.xml
Created April 4, 2018 14:02
Create external resource folder for tomcat 7
<Host>
...
<Context docBase="/var/img" path="/static" />
...
</Host>
@0xh3xa
0xh3xa / example.conf
Last active April 4, 2018 14:01
Configure Apache2 httpd as Reverse proxy with https support
<VirtualHost *:443>
ServerName exmple.com
ServerAlias *exmple.com
ServerAdmin user@gmail.com
ProxyPreserveHost On
ProxyRequests off
AllowEncodedSlashes NoDecode
<Proxy *>
Order deny,allow
@0xh3xa
0xh3xa / gist:a8df60a593d0e2549d87499c857c3228
Created July 25, 2017 19:22 — 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) | O(n) | O(n) | O(1) | Linked List
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array
@0xh3xa
0xh3xa / big-o-java-collections.md
Created July 25, 2017 19:21 — forked from FedericoPonzi/big-o-java-collections.md
Big O notation for java's collections

The book Java Generics and Collections has this information (pages: 188, 211, 222, 240).

List implementations:

                      get  add  contains next remove(0) iterator.remove
ArrayList             O(1) O(1) O(n)     O(1) O(n)      O(n)
LinkedList O(n) O(1) O(n) O(1) O(1) O(1)
spring.datasource.url=jdbc:mysql://google/<nameOfinstance>?cloudSqlInstance=<nameOfInstance>-164906:europe-west1:<nameOfInstance>&socketFactory=com.google.cloud.sql.mysql.SocketFactory&user=root&password=secret
//How to make an Ajax request from html to servlet.
//NOTE: Found is a variable in Servlet:
public void doGet(HttpRequest request, HttpResponse response) throws Exception{
String element = request.getParameter("element");
//TODO check the element Does it found in db or not?
boolean found = db.check();
response.getWriter().write(found);
}
var elements = [];
var tmp = [];
var Students = function (name, age) {
this.name = name;
this.age = age;
}
function addElementToArray(student){
elements.push(student);