Skip to content

Instantly share code, notes, and snippets.

View pavelgordon's full-sized avatar
🍻

Pavel Gordon pavelgordon

🍻
View GitHub Profile
@pavelgordon
pavelgordon / .p10k.zsh
Created April 5, 2023 09:13
.p10k.zsh
# Generated by Powerlevel10k configuration wizard on 2023-04-05 at 11:00 CEST.
# Based on romkatv/powerlevel10k/config/p10k-lean.zsh, checksum 53788.
# Wizard options: nerdfont-complete + powerline, small icons, unicode, lean, 1 line,
# compact, few icons, concise, instant_prompt=verbose.
# Type `p10k configure` to generate another config.
#
# Config for Powerlevel10k with lean prompt style. Type `p10k configure` to generate
# your own config based on it.
#
# Tip: Looking for a nice color? Here's a one-liner to print colormap.
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
zmodload zsh/zprof
export ZSH="/Users/pavelg/.oh-my-zsh"
@pavelgordon
pavelgordon / toolchains.xml
Created June 26, 2022 20:11
toolchains.xml
<?xml version="1.0" encoding="UTF-8"?>
<toolchains>
<!-- JDK toolchains -->
<toolchain>
<type>jdk</type>
<provides>
<version>6</version>
<vendor>sun</vendor>
</provides>
<configuration>
@pavelgordon
pavelgordon / sh
Created October 25, 2020 16:53
How to upgrade version of gradle for intellij idea projects
./gradlew wrapper --gradle-version 6.7
@pavelgordon
pavelgordon / build-gradle-for-fat-jar
Last active September 8, 2020 20:51
Build fat-jar/uber-jar(standalone executablejar file with all depencdencies). Run "shadowJar" task from gradle, and then see your jar at build/libs/app-0.0.1-all.jar
plugins {
id 'com.github.johnrengelman.shadow' version '6.0.0'
id 'java'
}
group 'dev.pgordon'
version '0.1.0'
@pavelgordon
pavelgordon / Dockerfile
Created September 8, 2020 19:53
Docker file for Gradle projects(e.g. Ktor). Requires jar file at build/libs/yourapp.jar directory(= run gradle build command before)
FROM openjdk:8-jre-alpine
ENV APPLICATION_USER ktor
RUN adduser -D -g '' $APPLICATION_USER
RUN ls -la
RUN mkdir /app
RUN chown -R $APPLICATION_USER /app
USER $APPLICATION_USER
@pavelgordon
pavelgordon / file.py
Created April 30, 2020 15:43
Downloads all posts from instagram in specific date range
import csv
from datetime import datetime
from instaloader import instaloader
def instaposts_streamer(query, date_from, date_to, filename):
cols = ['date', 'username', 'text', 'tags', 'permalink']
with open(filename, 'w') as f:
csv.writer(f, delimiter='|').writerow(cols)
@pavelgordon
pavelgordon / Clear-Docker-Images-etc
Last active September 8, 2020 20:53
Clear docker containters and images
I have a helper function to nuke everything so that our Continuous blah, cycle can be tested, erm... continuously. Basically it boils down to the following:
To clear containers:
docker rm -f $(docker ps -a -q)
To clear images:
docker rmi -f $(docker images -a -q)
@pavelgordon
pavelgordon / Main.kt
Last active April 9, 2020 16:07
Sorting
fun main() {
val s = "beans onion corn onion carrot potato avocado avocado carrot"
.split(" ")
.groupingBy { it }
.eachCount()
.toList()
.sortedWith(compareBy<Pair<String, Int>> { -it.second }.thenBy { it.first })
// .sortedWith(compareBy({ -it.second }, { it.first })) // also possible
.forEach { (k, v) ->
println("$v x $k")
import io.ktor.*
fun main(args: Array<String>) {
val server = embeddedServer(Netty, port = 8080) {
routing {
get("/") {
call.respondText("Hello World!", ContentType.Text.Plain)
}
get("/demo") {
call.respondText("HELLO WORLD!")