Skip to content

Instantly share code, notes, and snippets.

View jarek-przygodzki's full-sized avatar

Jarek Przygódzki jarek-przygodzki

View GitHub Profile
# Installation
$ dnf -y install sysstat
$ systemctl enable --now sysstat
# create a new config to override the default 10 minutes
$ systemctl edit sysstat-collect.timer
[Unit]
@jarek-przygodzki
jarek-przygodzki / git-core-longpaths.md
Last active July 10, 2023 15:40
How core.longpaths works in Git

I've recently looked into how core.longpaths Git options works and how it's related to Enable Win32 long paths Windows option. Turns out they are not related, and longpaths is both clever and hacky.

Many Windows wide char APIs support longer than MAX_PATH paths through the file namespace prefix (\\?\ or \\?\UNC\) followed by an absolute path. When long paths support is enabled via 'core.longpaths' option, handle_long_path function expands long paths using the '\?' file namespace prefix. See this commit message for detailed explantion.

@jarek-przygodzki
jarek-przygodzki / jvm-metaspace-size.md
Last active December 3, 2020 14:21
JVM - Find out size of metaspace at runtime

jinfo

jinfo -flag MaxMetaspaceSize <pid>

 jinfo -flag MaxMetaspaceSize 25244
-XX:MaxMetaspaceSize=1073741824 # 1073741824 = 1GiB

jcmd

Fibers

Fibers are an abstraction over sequential computation, similar to threads but at a higher level. There are two ways to think about this model: by example, and abstractly from first principles. We'll start with the example.

(credit here is very much due to Fabio Labella, who's incredible Scala World talk describes these ideas far better than I can)

Callback Sequentialization

Consider the following three functions

@jarek-przygodzki
jarek-przygodzki / maven-sleep.xml
Created October 8, 2020 06:36
How to introduce delay between executions in Maven
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<configuration>
<tasks>
<sleep seconds="10" />
</tasks>
</configuration>
<executions>
<execution>
@jarek-przygodzki
jarek-przygodzki / gist:be6961c8f0bb43f5959f21f081b44d19
Last active August 3, 2020 08:50
Global proxy settings on windows
# Explicit proxy server
Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' | Select-Object ProxyServer
# In case of proxy auto-config you can get the PAC file URL in registry
Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\AutoConfigURL'
@jarek-przygodzki
jarek-przygodzki / enable-disable-hibernate.txt
Last active June 27, 2020 14:14
Enable/Disable Hibernation in Windows
In elevated command prompt (Win+X)
Check status (look for HibernateEnabled: 0 means off, 1 means on)
> Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Control\Power -name HibernateEnabled
or
> reg query "HKLM\SYSTEM\CurrentControlSet\Control\Power" /v "HibernateEnabled"
Enable
> powercfg -h
or
@jarek-przygodzki
jarek-przygodzki / brew-install-log.txt
Last active April 27, 2020 17:53
Brew install log
jarekprzygodzki@Jareks-MacBook-Pro ~ % /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following existing directories will be made group writable:
import lombok.val;
import org.junit.Assert;
import org.junit.Test;
import java.lang.invoke.*;
/*
Your scientists were so preoccupied with whether or not they could, they didnt stop to think if they should.
Please don't actually do this... :P
@jarek-przygodzki
jarek-przygodzki / gist:5696ea6bf173e802894d6da6f365f16a
Created February 17, 2020 09:56
Postgres on Windows without the installer
Download ZIP file from https://www.enterprisedb.com/download-postgresql-binaries
Unpack to any directory of your choosing (C:\bin\pgsql)
PS C:\bin\pgsql> $env:PGDATA = "C:\bin\pgsql\data"
PS C:\bin\pgsql> .\bin\initdb "--username=postgres"
# postgres.exe vs pg_ctl.exe: see https://www.postgresql.org/docs/current/server-start.html
PS C:\bin\pgsql> .\bin\postgres.exe