Skip to content

Instantly share code, notes, and snippets.

View mario21ic's full-sized avatar
👋
Open to work

Mario IC mario21ic

👋
Open to work
View GitHub Profile
export CLUSTER_DNS=[...]
export CLUSTER_IP=[...]
ssh -i workshop.pem docker@$CLUSTER_IP
docker container run -d --name jenkins -p 8080:8080 jenkins:alpine
docker container ls # Wait until it is up and running
@mario21ic
mario21ic / Jenkinsfile.groovy
Created August 15, 2017 19:49 — forked from Faheetah/Jenkinsfile.groovy
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'No quotes in single backticks'
sh 'echo $BUILD_NUMBER'
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"'
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"'
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"'
echo 'Using three backslashes still results in preserving the single quotes'
@mario21ic
mario21ic / packer-ami-id
Created August 16, 2017 23:10 — forked from danrigsby/packer-ami-id
Get AMI ID from a packer build
packer build packer.json 2>&1 | sudo tee output.txt
tail -2 output.txt | head -2 | awk 'match($0, /ami-.*/) { print substr($0, RSTART, RLENGTH) }' > sudo ami.txt
@mario21ic
mario21ic / packer-ami-id
Created August 16, 2017 23:10 — forked from danrigsby/packer-ami-id
Get AMI ID from a packer build
packer build packer.json 2>&1 | sudo tee output.txt
tail -2 output.txt | head -2 | awk 'match($0, /ami-.*/) { print substr($0, RSTART, RLENGTH) }' > sudo ami.txt
@mario21ic
mario21ic / Jenkinsfile
Created August 29, 2017 19:17
Function to get the last successfull build in Jenkins
def lastSuccessfullBuild(build) {
if(build != null && build.result != 'FAILURE') {
return build.number;
} else {
lastSuccessfullBuild(build.previousBuild);
}
}
@mario21ic
mario21ic / postgres_queries_and_commands.sql
Created October 12, 2017 19:55 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@mario21ic
mario21ic / docker-compose.yml
Created October 24, 2017 21:23 — forked from franckweb/docker-compose.yml
Selenium Grid docker compose file with firefox and chrome
version: '2'
services:
seleniumhub:
container_name: seleniumhub
image: selenium/hub
ports:
- "4444:4444"
@mario21ic
mario21ic / main.py
Last active October 25, 2017 19:02
Python script to filter names and documents
#!/usr/bin/env python
import csv
import re
def extract_document(names_document):
return [int(s) for s in names_document.split() if s.isdigit()]
def extract_letters(names_document):
return " ".join(re.findall(r"(?i)\b[a-z]+\b", names_document))
@mario21ic
mario21ic / installr331loki.sh
Created October 27, 2017 00:32 — forked from ccortezb/installr331loki.sh
install R 3.3.1 on Elementary OS loki with R studio RGTK 2.2 and Rattle for Data mining
# Get R (base) and a few dependencies for packages
sudo apt-get -y install r-base libapparmor1 libcurl4-gnutls-dev libxml2-dev libssl-dev
sudo su - -c "R -e \"install.packages('tidyverse', repos = 'http://cran.rstudio.com/')\""
sudo su - -c "R -e \"install.packages('devtools', repos='http://cran.rstudio.com/')\""
sudo su - -c "R -e \"devtools::install_github('daattali/shinyjs')\""
sudo su - -c "R -e \"install.packages('rmarkdown', repos='http://cran.rstudio.com/')\""
# install java8
sudo apt install openjdk-8-jdk
@mario21ic
mario21ic / BaseDao.kt
Created October 28, 2017 20:50 — forked from florina-muntenescu/BaseDao.kt
Use Dao inheritance to reduce the amount of boilerplate code
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software