Skip to content

Instantly share code, notes, and snippets.

@calo81
calo81 / LoggerFilter
Created March 18, 2012 12:48
Filter for reading and logging HttpServletRequest body, and resetting the input stream
package com.paddypower.financials.market.management.rest.logging;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
@kwikwag
kwikwag / HelloPrint.java
Created April 10, 2012 10:56
sample print app trying to monitor a print job in progress
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.net.URI;
import java.util.Date;
import java.util.Locale;
import javax.print.Doc;
import javax.print.DocFlavor;
import javax.print.DocPrintJob;
import javax.print.PrintException;
@gilyes
gilyes / Backup, restore postgres in docker container
Last active June 11, 2024 21:21
Backup/restore postgres in docker container
Backup:
docker exec -t -u postgres your-db-container pg_dumpall -c > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
Restore:
cat your_dump.sql | docker exec -i your-db-container psql -Upostgres
@zulhfreelancer
zulhfreelancer / git_logs_between_2_commits.md
Created January 4, 2017 07:06
How to see Git logs between 2 commits?
git log --oneline 7de7970..master

OR

git log --oneline 7de7970..4cb34a9

Above command will give all logs between commit A and commit B including commit A and commit B.

@smoser
smoser / .gitignore
Last active April 1, 2024 07:38
cloud-init ubuntu nocloud example with network config
*.img
*.raw
@itzg
itzg / LoginWebFilter.java
Created April 22, 2018 13:10
Custom Spring WebFlux AuthenticationWebFilter
import org.springframework.http.HttpMethod;
import org.springframework.http.codec.ServerCodecConfigurer;
import org.springframework.security.authentication.ReactiveAuthenticationManager;
import org.springframework.security.web.server.authentication.AuthenticationWebFilter;
import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatchers;
public class LoginWebFilter extends AuthenticationWebFilter {
private final ServerCodecConfigurer serverCodecConfigurer;
/**
@unoexperto
unoexperto / patch_apk_for_sniffing.md
Last active July 5, 2024 02:41
How to patch Android app to sniff its HTTPS traffic with self-signed certificate

How to patch Android app to sniff its HTTPS traffic with self-signed certificate

  • Download apktool from https://ibotpeaches.github.io/Apktool/
  • Unpack apk file: java -jar /home/expert/work/tools/apktool.jar d net.flixster.android-9.1.3@APK4Fun.com.apk
  • Modify AndroidManifest.xml by adding android:networkSecurityConfig="@xml/network_security_config" attribute to application element.
  • Create file /res/xml/network_security_config.xml with following content:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config>
@rmkraus
rmkraus / unifi_dhcp_automation.yml
Last active March 15, 2024 03:37
Ansible Automation for Static DHCP Entries on UniFi Gear
#!/usr/bin/ansible-playbook
# more api documentation here:
# https://ubntwiki.com/products/software/unifi-controller/api
---
- name: test unifi api
hosts: localhost
gather_facts: no
vars:
unifi_user: SVC_ACCT_USERNAME
@qzm
qzm / aria2.conf
Last active June 6, 2024 19:23
Best aria2 Config
### Basic ###
# The directory to store the downloaded file.
dir=${HOME}/Downloads
# Downloads the URIs listed in FILE.
input-file=${HOME}/.aria2/aria2.session
# Save error/unfinished downloads to FILE on exit.
save-session=${HOME}/.aria2/aria2.session
# Save error/unfinished downloads to a file specified by --save-session option every SEC seconds. If 0 is given, file will be saved only when aria2 exits. Default: 0
save-session-interval=60
# Set the maximum number of parallel downloads for every queue item. See also the --split option. Default: 5
@markruler
markruler / cgroup.memory.md
Last active February 2, 2023 11:25
cgroup.memory "cannot allocate memory"

"cannot allocate memory"

kubectl get pod -A --field-selector spec.nodeName=worker-node -o wide
kubectl describe pod calico-node-hh2g8 -n kube-system