Skip to content

Instantly share code, notes, and snippets.

View emrekgn's full-sized avatar

Emre Kağan Akkaya emrekgn

View GitHub Profile
@emrekgn
emrekgn / RepoSourcesListParser.java
Last active December 1, 2015 18:02
sources.list URL Parser - Prints out packages defined by repository URL
package tr.org.sources.list.parser;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Set;
@emrekgn
emrekgn / checkstyle.xml
Created February 22, 2016 20:53
Checkstyle configuration for Google coding conventions
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!--
Source = https://github.com/checkstyle/checkstyle/tree/master/src/main/resources
Checkstyle configurartion that checks the Google coding conventions from:
- Google Java Style
@emrekgn
emrekgn / AhenkPlugin.cs
Last active November 4, 2016 14:34
Sample Implementation for Ahenk pGina Plugin
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using pGina.Shared.Types;
using log4net;
/*
* See https://github.com/pgina/pgina/wiki/Plugin-Tutorial

blueprint.xml

The possible reference :

blueprintBundle Provides bundle's Bundle object.

@emrekgn
emrekgn / when-to-use-jta-xa.md
Created September 21, 2017 12:31
When to use JTA / XA

When to use?

JTA/XA is a kind of system insurance against data corruption (and the resulting business losses). The most common use cases are: Processing JMS messages from a queue and inserting the results in a database: you don't want a crash to lose messages whose results are not yet stored in the database. Updating two or more legacy back-end systems in the same transaction In general, whenever you access more than one back-end system in the same transaction the use of JTA/XA is highly recommended. Otherwise, the risk of data loss or corruption is too high (and not necessarily visible!). Many programmers try to avoid the "overhead" of JTA/XA by programming application-specific recovery code (such as trying to handle duplicate requests, storing extra state in the database, etc). However, all these approaches are brittle (not reusable, application-specific, and hard to test). In the end, the perceived overhead of JTA/XA is often replaced by equivalent but buggy overhead at the application level.

A sample

@emrekgn
emrekgn / list-users.ps1
Last active October 9, 2017 11:06
Powershell Tricks - List Users with groups, home directory and disabled status
#
# Prints user name, groups, home directory and disabled status
#
$adsi = [ADSI]"WinNT://$env:COMPUTERNAME"
$adsi.Children | where { $_.SchemaClassName -eq 'user' } | Foreach-Object {
$groups = $_.Groups() | Foreach-Object {
$_.GetType().InvokeMember('Name', 'GetProperty', $null, $_, $null)
}
$user = Get-WmiObject Win32_UserAccount -filter "LocalAccount=True AND Name='$($_.Name)'"
@emrekgn
emrekgn / XmppClient.java
Created November 29, 2015 18:17
Smack API example (uses Smack v4.1.5)
package xmpp.client.example;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Collection;
import org.jivesoftware.smack.AbstractXMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode;
import org.jivesoftware.smack.SmackException.NotConnectedException;
@emrekgn
emrekgn / README.md
Created October 16, 2020 10:34 — forked from hofmannsven/README.md
Git Cheatsheet
@emrekgn
emrekgn / README-fail2ban-keycloak.md
Created December 16, 2021 19:16 — forked from drmalex07/README-fail2ban-keycloak.md
Use fail2ban to block brute-force attacks to keycloak server. #keycloak #fail2ban #brute-force-attack

Add regular-expression filter under /etc/fail2ban/filter.d/keycloak.conf:

[INCLUDES]

before = common.conf

[Definition]

_threadName = [a-z][-_0-9a-z]*(\s[a-z][-_0-9a-z]*)*
_userId = (null|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})
@emrekgn
emrekgn / latex-tr.md
Created November 30, 2018 08:28
LATEX Türkçe karakterler
  • \u{g} – ğ
  • \u{G} – Ğ
  • \c{c} – ç
  • \c{C} – Ç
  • \c{s} – ş
  • \c{S} – Ş
  • \”{u} – ü
  • \”{U} – Ü
  • \”{o} – ö
  • \”{O} – Ö