Skip to content

Instantly share code, notes, and snippets.

@yilazius
yilazius / snippets.clj
Created June 5, 2018 20:19
Clojure snippets
; destructering nested map with let bindings
(defn my-transformer
[event]
(let [{type :type, {id :id} :data} event]
{:type type :data {:id id}}))
@yilazius
yilazius / template.cheatsheet
Last active July 26, 2017 21:03
Angular 2 cheatsheet
## template expressions
<h1>{{title}}</h1> -> interpolation binding syntax (represent's components title property value as String)
{{1+1}} -> template expression - evaluated and then converted to a string
{{1 + 1 + getVal()}} -> getVal is method on host component
<div *ngFor="let hero of heroes">{{hero.name}}</div> -> hero property is defined in the template's context
## template statements
button (click)="deleteHero()">Delete hero</button> -> template statement used in event bindings, deleteHero is a side effect
@yilazius
yilazius / WorkOnFork.scala
Created February 3, 2017 20:25
To fork or not to fork that is the question :)
def knowsHowToUseGit(user:User) = {
if(isAbleToExplainWhyNotToPushToMaster(user) &&
knowsHowToWorkOnBranches(user) &&
isFamiliarWithInteractiveRebasing(user) &&
knowsHowToScopeACommit(user))
true
false
}
def workOnFork(user:User,repository:Repository) = {
@yilazius
yilazius / fluent-api.java
Last active January 22, 2017 19:11
Readability of Clojure and the thread-last macro
IntStream.of(3, 4, 5, 6).
filter(this::even).
map(i -> i * 2).
reduce(Integer::sum);
@yilazius
yilazius / PortfolioInteractor.java
Created January 19, 2017 01:36
Mocking in Groovy
public class PortfolioInteractor {
private final PortfolioService portfolioService;
public PortfolioInteractor(@Inject PortfolioService portfolioService){
this.portfolioService = portfolioService;
}
public void addToPortfolio(final Isin isin, final Integer count) {
Optional<PortfolioEntry> existingEntry = portfolioService.get(isin);
PortfolioEntry newEntry = existingEntry.map(e -> e.count = e.count + count).orElse(PortfolioEntry.of(isin,count))
@yilazius
yilazius / intellij.cheatsheet
Last active October 26, 2016 21:11
IntelliJ shortcuts which are valuable and I tend to forget
#Highlight usage of marked variable
Command + Shift + F7
#Find next occurence of marked variabel or search result:
F3
#Find previous occurence
Shift + F3
#Find next highlighted error
F2
#Find previous highlighted error
Shift + F2
@yilazius
yilazius / git.cheatsheet
Last active October 26, 2016 21:12
Collection of git commands which aren't covered by my git.config
# only diff staged files
git diff --staged
# add all files indepent of folder - skips unix file resolution
git add '.txt'
# change the author of the last commit
git commit --amend --author "yilaziys <fun.fun.fun@fun.fun>"
## change the author of the last three commits
git rebase -i HEAD~3
#mark the commit that needs re-autoring with e
@yilazius
yilazius / MacOSx.setup
Last active November 26, 2022 17:27
Mac Setup
brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap caskroom/cask
brew cask install java
brew cask install google-chome
* Adblock plugin
brew cask install iterm2
* https://coderwall.com/p/h6yfda/use-and-to-jump-forwards-backwards-words-in-iterm-2-on-os-x
* powerline font https://gist.github.com/baopham/1838072
@yilazius
yilazius / cheatsheet.docker.bash
Last active February 24, 2017 07:14
docker cheatsheet
#docker-compose start/stop
docker-compose up
docker-compose stop
#create docker container with name
docker run --name yil-mysql-5.6 --env="MYSQL_ROOT_PASSWORD=password" -v /yilazius/var/lib/mysql:/var/lib/mysql -p 3306:3306 -d mysql/mysql-server:5.6
#start/stop by _name_ or _container id_
docker start mysql-5.6
docker stop mysql-5.6
#list running docker container