Skip to content

Instantly share code, notes, and snippets.

View adixchen's full-sized avatar
💭
bookmarking for developers

Adrian Matei adixchen

💭
bookmarking for developers
View GitHub Profile
@adixchen
adixchen / LanguageType.java
Created October 9, 2019 12:58
language type enum
@XmlType(name = "LanguageType")
@XmlEnum
public enum LanguageType {
@XmlEnumValue("de")
DE("de"),
@XmlEnumValue("fr")
FR("fr"),
@XmlEnumValue("it")
IT("it"),
@adixchen
adixchen / usesful-helm.sh
Created August 15, 2019 10:40
everyday helm charts commands
#list current releases
helm ls
#list of helm repositories
helm repo list
#show all charts in the `chartmuseum` repo
helm search chartmusem
#start chartmuseum with port and file (local storage) (for localtesting)
chartmuseum --port=8090 --storage="local" --storage-local-rootdir="~/chart-storage"
@adixchen
adixchen / immutable_removal_by_index.js
Created July 24, 2019 13:49
Immutable removal of element from list by index
const immutableRemoval = (list, index) => {
return [
...list.slice(0, index),
...list.slice(index+1)
];
};
const v = [1,2,3];
console.log(immutableRemoval(v,1));
// [1,3]
@adixchen
adixchen / kubernetes-useful.sh
Last active August 21, 2019 08:11
kubernetes useful commands
# install and delete keycloak helm chart
## install
cd /Users/maad4/projects/training/codecentric-helm-charts/charts/keycloak;
helm install --name keycloak .
## delete
helm delete --purge keycloak
# secrets
## create cloudsql-instance-credentials secret
kubectl create secret generic cloudsql-instance-credentials --from-file=credentials.json
@adixchen
adixchen / docker-and-docker-compose-usual-commands.sh
Last active June 20, 2019 13:39
docker and docker-compose usual commands
# docker
## inspect
# - get ip address of the container named "my_container"
$ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' my_container
$ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' fb4d0e863eb0 # same but with container_id
## stop
$ docker stop my_container # stop conatainer named "my_container"
$ docker stop $(docker ps -a -q) # stop all running containers
@adixchen
adixchen / docker-command.sh
Last active November 6, 2018 12:56
dockerize existing mongo db (v3)
docker run --name mongo -p 27017:27017 -v /data/db:/data/db mongo:3.4.17-jessie
/**
* In this example we'll GET a codingmark identified by its location callling the following REST resource
* https://www.codingmarks.org/public/codingmarks?location={myLocation}
* which is protected with Basic-Authentication
**/
import javax.ws.rs.NotFoundException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.MediaType;
@adixchen
adixchen / get_keycloak_access_token.sh
Last active August 31, 2021 14:14
Get Keycloak access token via curl and pretty print it with python
curl \
-d 'client_id=YOUR_KEYCLOAK_CLIENT' \
-d 'username=YOUR_USERNAME' \
-d 'password=YOUR_PASSWORD' \
-d 'grant_type=password' \
'https://YOUR_KEYCLOAK_SERVER_HOST/auth/realms/YOUR_REALM/protocol/openid-connect/token' \
| python -m json.tool
var Person = function (firstName) {
this.firstName = firstName;
};
Person.prototype.sayHello = function() {
console.log("Hello, I'm " + this.firstName);
};
var person1 = new Person("Alice");
var person2 = new Person("Bob");
@adixchen
adixchen / CreateOutputFilePathMethod.java
Last active August 29, 2015 14:06
Method showing how to create a "weeknum" directory in Java and build a file name/file path having the current timestamp to the minute in it...
private static String getOutputFilePath() throws Exception {
//create if not existent a "weeknum" directory in the given "output.directory.base" directory
Date now = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(now);
int weeknum = calendar.get(Calendar.WEEK_OF_YEAR);
String targetDirPath = System.getProperty("output.directory.base") + String.valueOf(weeknum);
File targetDirectory = new File(targetDirPath);
if(!targetDirectory.exists()){