Skip to content

Instantly share code, notes, and snippets.

View jarek-przygodzki's full-sized avatar

Jarek Przygódzki jarek-przygodzki

View GitHub Profile
@jarek-przygodzki
jarek-przygodzki / force-git-to-use-lf-everywhere.md
Created November 28, 2019 07:45
Force Git to use LF everywhere

It's safe to use LF everywhere now

git config --global core.eol lf
git config --global core.autocrlf input

Make sure all local files are recreated with the correct line-endings

@jarek-przygodzki
jarek-przygodzki / iptables-reset.sh
Last active February 28, 2023 21:58
Reset iptables rules (IPv4, IPv6)
iptables -P INPUT ACCEPT && \
iptables -P FORWARD ACCEPT && \
iptables -P OUTPUT ACCEPT && \
iptables -F INPUT && \
iptables -F OUTPUT && \
iptables -F FORWARD && \
iptables -F && \
iptables -t nat -F && \
iptables -t mangle -F && \
iptables -X && \
@jarek-przygodzki
jarek-przygodzki / docker-cant-run-tshark-as-root.sh
Last active February 6, 2023 17:23
tshark: Couldn't run /usr/sbin/dumpcap in child process: Operation not permitted
$ whoami
root
$ tshark
tshark: Couldn't run /usr/sbin/dumpcap in child process: Operation not permitted
Are you a member of the 'wireshark' group? Try running
'usermod -a -G wireshark _your_username_' as root.
$ stat $(which dumpcap)
File: '/usr/sbin/dumpcap'
@jarek-przygodzki
jarek-przygodzki / PostgreSQL.groovy
Created February 9, 2013 20:12
Howto connect to PostgreSQL DB in Groovy
import groovy.sql.Sql
def dbUrl = "jdbc:postgresql://localhost/test-db"
def dbUser = "test"
def dbPassword = "test"
def dbDriver = "org.postgresql.Driver"
def sql = Sql.newInstance(dbUrl, dbUser, dbPassword, dbDriver)
@jarek-przygodzki
jarek-przygodzki / tx-elist-delist.md
Last active January 20, 2023 15:49
TX enlistResource/delistResource

enlistResource

at java.net.SocketInputStream.socketRead0(java.base@11.0.17/Native Method)
at java.net.SocketInputStream.socketRead(java.base@11.0.17/SocketInputStream.java:115)
at java.net.SocketInputStream.read(java.base@11.0.17/SocketInputStream.java:168)
at java.net.SocketInputStream.read(java.base@11.0.17/SocketInputStream.java:140)
at com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.readInternal(IOBuffer.java:1023)
at com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.read(IOBuffer.java:1013)
at sun.security.ssl.SSLSocketInputRecord.read(java.base@11.0.17/SSLSocketInputRecord.java:478)
at sun.security.ssl.SSLSocketInputRecord.readHeader(java.base@11.0.17/SSLSocketInputRecord.java:472)
@jarek-przygodzki
jarek-przygodzki / debug-jvm-in-docker.md
Last active December 13, 2022 13:19
Debugging any JVM in a Docker container
# docker run
-e "JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" \
-p 5005:5005

# docker-compose
    environment:
      - "JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
    ports:
 - 5005:5005
@jarek-przygodzki
jarek-przygodzki / dfs-recursive-generator.js
Created June 13, 2016 10:53
Recursive DFS using ES6 generator
class Node {
constructor(name, childNodes) {
this.name = name;
this.childNodes = childNodes;
this.visited = false;
}
}
function *dfs(u) {
u.visited = true;
@jarek-przygodzki
jarek-przygodzki / centos-install-kernel-debuginfo.sh
Created February 16, 2017 20:23
CentOS 7 - How to install kernel-debuginfo
yum --enablerepo=base-debuginfo install -y kernel-debuginfo-$(uname -r)
@jarek-przygodzki
jarek-przygodzki / gist:a2d94452217aaadeb90aa3dec9cf9bb4
Last active September 12, 2022 07:44
OpenJDK + jmap - unknown CollectedHeap type : class sun.jvm.hotspot.gc_interface.CollectedHeap
$ jmap -heap 66
Attaching to process ID 66, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.111-b14
using parallel threads in the new generation.
using thread-local object allocation.
Concurrent Mark-Sweep GC
@jarek-przygodzki
jarek-przygodzki / rob-pike-comments.md
Last active September 9, 2022 08:33
Rob Pike on commnts

Comments

A delicate matter, requiring taste and judgement. I tend to err on the side of eliminating comments, for several reasons. First, if the code is clear, and uses good type names and variable names, it should explain itself. Second, comments aren't checked by the compiler, so there is no guarantee they're right, especially after the code is modified. A misleading comment can be very confusing. Third, the issue of typography: comments clutter code.

Rob Pike, "Notes on Programming in C"