Skip to content

Instantly share code, notes, and snippets.

View alexengrig's full-sized avatar
☮️
Make jar, not war!

Grig Alex alexengrig

☮️
Make jar, not war!
View GitHub Profile
@alexengrig
alexengrig / PECS.java
Last active June 24, 2020 20:43
PECS (Producer Extends Consumer Super) - Java generic wildcards
public class PECS {
public static void main(String[] args) {
// PECS (Producer Extends Consumer Super)
// Consumer
List<? super Number> consumerNumbers = new ArrayList<>();
consumerNumbers.add(Byte.valueOf((byte) 1));
consumerNumbers.add(Short.valueOf((short) 1));
consumerNumbers.add(Integer.valueOf((int) 1));
consumerNumbers.add(Long.valueOf((long) 1));
curl -fsSL get get.docker.com -o get-docker.sh
sh get-docker.sh
docker -v
sudo usermod -aG docker $USER
@alexengrig
alexengrig / LiveTemplate-jsConsoleLog.md
Last active April 18, 2020 12:35
Live Template - js console.log(")

Live Template - js console.log(") for JetBrains

Go to Settings > Editor > Live Templates > JavaScript > Add (+)

Abbreviation:

log

Description:

Inserts console.log(")

Template text:

console.log('Class: $CLASS$, Function: $FUNCTION$, Line $LINE$ $PARAM_TEXT$($EXPECTED$): ', 
 $PARAM$);$END$
@alexengrig
alexengrig / .babelrc
Created January 22, 2019 19:25
ES7 async/await
{
"presets": ["es2015"],
"plugins": [
"syntax-async-functions",
"transform-regenerator",
[
"transform-runtime",
{
"polyfill": false,
"regenerator": true
@alexengrig
alexengrig / createReduce.js
Last active March 5, 2019 11:48
Function of create a reduce function for Redux store
function createReduce(reducer = {}, initialState) {
return (state = initialState, action) => {
const { type: actionType } = action;
const func = reducer[actionType];
const newState = typeof func === 'function' ? func.call(reducer, state, action) : undefined;
return newState !== undefined ? newState : state;
};
}
// example
@alexengrig
alexengrig / FixedRouter.jsx
Last active March 5, 2019 12:40
Fix react-router problem with encoding the percent character in url
import React from 'react';
import { Router } from 'react-router-dom';
import { createBrowserHistory } from 'history';
function FixedRouter({ history = createBrowserHistory(), children }) {
const originalPush = history.push;
// monkey patching
history.push = (url, ...args) =>
originalPush(
url.replace(/%/g, percent => encodeURI(encodeURI(percent))),
@alexengrig
alexengrig / .npmbundlerrc
Last active March 11, 2019 20:46
Liferay imports
{
"config": {
"imports": {
"first-react-portlet": {
"react": "15.6.2",
"react-dom": "15.6.2"
}
}
}
}
@alexengrig
alexengrig / e-cards_.babelrc
Created August 21, 2019 12:00
Liferay React Portlet Template
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-transform-destructuring"
]
}
@alexengrig
alexengrig / TextWithLinks.js
Created April 1, 2020 09:42
React - text with links
@alexengrig
alexengrig / BuilderExample.java
Last active April 21, 2020 10:43
Builder with Inheritance
public class BuilderExample {
public static void main(String[] args) {
User user = new UserBuilder().id(1).name("One").build();
}
}
class Entity {
protected int id;
public Entity(int id) {