Skip to content

Instantly share code, notes, and snippets.

View KomanRudden's full-sized avatar

Koman Rudden KomanRudden

  • BMW
  • South Africa
View GitHub Profile
@KomanRudden
KomanRudden / aws
Last active March 16, 2021 18:55
AWS CLI Commands
List S3 buckets
>aws s3 ls
List bucket contents
>aws s3 ls s3://bucket --human-readable --summarize
Copy S3 bucket contents to local drive
>aws s3 sync s3://bucket .
Get S3 bucket file permissions
@KomanRudden
KomanRudden / kafka-topic
Last active January 19, 2021 18:26
Kafka Topics CLI
List all topics
>kafka-topics.sh --bootstrap-server localhost:9092 --list
my-topic
Create new topic
>kafka-topics.sh --bootstrap-server localhost:9092 --create --topic my-topic --replication-factor 3 --partitions 3
Created topic my-topic
@KomanRudden
KomanRudden / Beautiful terminal
Created February 15, 2020 06:13
Beautify your terminal in Linux
sudo apt install fonts-powerline
Paste the following into your .bashrc
################################################################################
## FUNCTIONS ##
################################################################################
##
## ARRANGE $PWD AND STORE IT IN $NEW_PWD
sudo apt-key list | \
grep "expired: " | \
sed -ne 's|pub .*/\([^ ]*\) .*|\1|gp' | \
xargs -n1 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys
Command explanation:
sudo apt-key list - lists all keys installed in the system;
grep "expired: " - leave only lines with expired keys;
sed -ne 's|pub .*/\([^ ]*\) .*|\1|gp' - extracts keys;
@KomanRudden
KomanRudden / Docker commands
Last active March 17, 2021 18:44
Docker commands
docker pull pull a pre-built image from the public repos
docker run run the container in one of 3 modes - Background, Foreground, Interactive
docker ps obtain a list of running containers
docker ps -a obtain a list of both running and stopped containers
docker images obtain a list of all images
docker rm remove container
docker container prune remove stopped containers
docker rmi remove image
docker logs view the logs of the running job
docker commit save the container state as an image
@KomanRudden
KomanRudden / XPath example
Last active May 18, 2016 08:49
XPath with namespace
<?xml version="1.0" encoding="UTF-8"?>
<persons xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.ods.co.za" xsi:schemaLocation="http://www.ods.ca.za PersonService.xsd">
<person isn="3101111" userID="SOFXX" timestamp="2010-02-27T07:36:48+02:00" millis="200">
<partyID> 2831762 </partyID>
<idNumber type="ID_NUMBER">
<number> 7777777777777 </number>
</idNumber>
<incomeTaxNumber> 1091919191 </incomeTaxNumber>
<title> Ms </title>
<surname> FIRST </surname>
@KomanRudden
KomanRudden / Spring 4 REST Client example - RestTemplate
Created May 5, 2016 06:39
Spring 4 REST Client example - RestTemplate
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
headers.add(ProcessEngineConstants.AUTHOURIZED_USERNAME, username);
HttpEntity<Object> requestEntity = new HttpEntity<Object>("request_headers", headers);
Map<String, Object> restParams = new HashMap<>();
restParams.put("business_key", "123");
try {
@KomanRudden
KomanRudden / Find java home on OS X
Created March 23, 2016 19:11
Find java home on OS X
From the command line
/usr/libexec/java_home -v 1.8
@KomanRudden
KomanRudden / AngularJS numeric directive
Created March 18, 2016 11:12
AngularJS numeric directive
var app = angular.module('permgen.directives');
app.directive('numbersOnly', function () {
return {
require: 'ngModel',
link: function (scope, element, attr, ngModelCtrl) {
function fromUser(text) {
if (text) {
var transformedInput = text.replace(/[^0-9]/g, '');
if (transformedInput !== text) {
@KomanRudden
KomanRudden / Read file from resources
Created March 18, 2016 08:33
Read file from resources
ClassLoader classLoader = getClass().getClassLoader();
File file = new File(classLoader.getResource("theFile.xml").getFile());