Skip to content

Instantly share code, notes, and snippets.

@pavelfomin
pavelfomin / using-multiple-github-accounts-with-ssh-keys.md
Last active July 11, 2025 20:41
Using multiple github accounts with ssh keys

From https://gist.github.com/oanhnn/80a89405ab9023894df7

Problem

I have two Github accounts: defaul for work and personal. I want to use both accounts on same computer via git ssh (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (an alias per account).

How to?

@pavelfomin
pavelfomin / DateCellEditor.java
Last active January 27, 2020 21:33
Java Swing JTable date cell editor based on JSpinner and JFormattedTextField
import javax.swing.*;
import javax.swing.table.TableCellEditor;
import java.awt.*;
import java.util.Calendar;
import java.util.Date;
/**
* DateCellEditor that is based on {@link JSpinner} and {@link JFormattedTextField}.
*/
public class DateCellEditor extends AbstractCellEditor implements TableCellEditor {
@pavelfomin
pavelfomin / DateFormatterTest.java
Last active January 8, 2020 21:38
JUnit 5 Parameterized Test example
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.aggregator.ArgumentsAccessor;
import org.junit.jupiter.params.converter.ConvertWith;
import org.junit.jupiter.params.provider.CsvSource;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import static org.junit.jupiter.api.Assertions.assertEquals;
@pavelfomin
pavelfomin / liferay-web-content-request-parameters.ftl
Last active January 22, 2022 14:35
Get the http request parameters in Liferay from the freemarker web content template
<#--
The request here is not the original request and doesn't contain the url query parameters
hence the usage of the serviceContext from ServiceContextThreadLocal.
-->
<#assign serviceContext = staticUtil["com.liferay.portal.service.ServiceContextThreadLocal"].getServiceContext()>
<#assign httpServletRequest = serviceContext.getRequest()>
myparam="${(httpServletRequest.getParameter('myparam')?html)!''}"