Skip to content

Instantly share code, notes, and snippets.

@nsarvar
nsarvar / FieldUtils.java
Created July 17, 2021 15:58 — forked from jasper-vandemalle/FieldUtils.java
FieldUtils mutates and accesses fields using reflection.
package be.vandemalle.jasper.util.reflection;
import java.lang.reflect.Field;
import org.apache.commons.lang.StringUtils;
public class FieldUtils {
/**
* Get the specified field on the class. If the field is not found on the class itself will recursively check
* the superclass.
@nsarvar
nsarvar / gist:e851f89e158780504d1e2e243e6fbfe1
Created March 16, 2021 07:38 — 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
@nsarvar
nsarvar / postgres_queries_and_commands.sql
Created May 11, 2018 12:45 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'