Skip to content

Instantly share code, notes, and snippets.

View eduardocardoso's full-sized avatar

Eduardo Cardoso eduardocardoso

View GitHub Profile
@eduardocardoso
eduardocardoso / main.py
Created March 1, 2019 17:15
Generating a JWT token
from __future__ import absolute_import
from time import time
import jwt
ISSUER = '8eb12629d265493588af989decb91209'
@eduardocardoso
eduardocardoso / gitlab-runner@.service
Last active June 16, 2016 21:16
Gitlab Runner service
[Unit]
Description=GitLab Runner
[Service]
ExecStartPre=-/usr/bin/docker rm gitlab-runner-%i
ExecStartPre=-/usr/bin/docker pull gitlab/gitlab-runner:latest
ExecStart=/usr/bin/docker run --name gitlab-runner-%i \
-v /var/run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner:latest
ExecStartPost=/opt/bin/runner-register.sh %i
@eduardocardoso
eduardocardoso / Linux.sh
Last active October 21, 2016 15:38
Shell script to install pip packages and add them to requirements.txt
pipi() {
REQ_FILE=requirements.txt
TMP_FILE=/tmp/tmp_req.txt
pip install "$@"
if [ $? -eq 0 ] && [ -f "${REQ_FILE}" ]
then
FREEZE="$(pip freeze)"
for arg in "$@"
do
@eduardocardoso
eduardocardoso / gist:0e7e61c173328db9d7e4
Created January 7, 2016 12:52
Function to post data without having to create html elements beforehand
function postData(url, data) {
var theDiv = document.createElement('div');
theDiv.style.display = 'none';
var theForm = document.createElement('form');
theForm.action = url;
theForm.method = 'post';
for (var key in data) {
@eduardocardoso
eduardocardoso / gist:99d970801a3879ba853d
Last active January 6, 2016 12:56
Script to download all images from facebook comments
var arr = [];
var imgs = document.querySelectorAll('div.mvs a[ajaxify]');
for (var i = 0; i < imgs.length; i++) { arr.push(imgs[i]); }
var a = document.createElement('a');
var re = RegExp("[?&]src=[^&]+")
arr.forEach(function (img) {
ajaxify = img.getAttribute('ajaxify');
encoded_img_url = re.exec(ajaxify)[0].substr(5);
decoded_img_url = decodeURIComponent(encoded_img_url);
a['href'] = decoded_img_url;
@eduardocardoso
eduardocardoso / gist:82a629882ddb02ab3677
Last active April 3, 2023 08:23
Script to delete exited containers and untagged/unused images from docker
#!/bin/bash
set -o errexit
echo "Removing exited docker containers..."
docker ps -a -f status=exited -q | xargs -r docker rm -v
echo "Removing dangling images..."
docker images --no-trunc -q -f dangling=true | xargs -r docker rmi