Skip to content

Instantly share code, notes, and snippets.

Félix Voituret Faylixe

View GitHub Profile
View postgres_queries_and_commands.sql
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), 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(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
View MenuBarBuilder#createFileMenu().java
/** ... **/
controller.accept(builder.createItem("Save", controller::save));
/** ... **/
Faylixe /
Last active Dec 7, 2015
Sample for menu builder
public interface Controller extends Consumer<Runnable>
View MenuBuilder#createActivable(String, ActionListener).java
public Runnable createActivable(final String label, final ActionListener listener) {
final JMenuItem item = createItem(label, listener);
return () -> item.setEnabled(true);
View MenuBarBuilder#build(Controller).java
public static JMenuBar build(final Controller controller) {
final MenuBuilder builder = new MenuBuilder(controller);
return builder.get();
View MenuBarBuilder#createFileMenu().java
/** Creates File menu and plug it to the target menu bar. **/
private void createFileMenu() {
final MenuBuilder builder = new MenuBuilder(new JMenu("File"));
builder.createItem("Open", controller::open);
builder.createItem("Save", controller::save);
builder.createItem("Exit", controller::exit);
You can’t perform that action at this time.