Skip to content

Instantly share code, notes, and snippets.

@raphaelcastaneda
raphaelcastaneda / .golangci.yml
Created April 12, 2023 20:44 — forked from maratori/.golangci.yml
Golden config for golangci-lint
# This code is licensed under the terms of the MIT license.
## Golden config for golangci-lint v1.52.2
#
# This is the best config for golangci-lint based on my experience and opinion.
# It is very strict, but not extremely strict.
# Feel free to adopt and change it for your needs.
run:
# Timeout for analysis, e.g. 30s, 5m.
@raphaelcastaneda
raphaelcastaneda / edgemax-ad-blocker-dnsmasq.md
Created January 14, 2023 09:34 — forked from martinsohn/edgemax-ad-blocker-dnsmasq.md
HOWTO Ubiquity EdgeMAX Ad & Malware Blocking Content Filtering using EdgeRouter as dnsmasq server

Ubiquity EdgeMAX Ad & Malware Blocking Content Filtering using EdgeRouter

NB: I am not using this setup anymore, and will not update the config and code if it breaks. I recommend Pi-hole instead, which gives many features such as web UI, statistics, DNS-over-HTTPS, and definitely better written code ;)

This will show you how to use your EdgeRouter as a local DNS server and blocking DNS queries to domains that hosts ads and malware.

The blocklist used is:

@raphaelcastaneda
raphaelcastaneda / pythonlogger.json
Created September 2, 2020 01:06
lnav python logger interpretter
{
"pythonlogger": {
"title": "Python logger format",
"description": "Log format used by python logger class",
"url": "",
"regex": {
"main": {
"pattern": "^\\[(?<timestamp>\\d{4}\\-\\d{2}\\-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3})] (?<level>\\w+) (?<module>(\\w(\\.)?)+) \\- (?<body>.*)$"
}
},
@raphaelcastaneda
raphaelcastaneda / configure_jenkins_artifactory.groovy
Created April 15, 2020 18:58
Configuring jenkins artifactory plugin from a groovy script
import jenkins.model.*
import org.jfrog.hudson.ArtifactoryBuilder
import org.kohsuke.stapler.Stapler
import net.sf.json.JSONObject
def instance = Jenkins.getInstance()
def descriptor = instance.getDescriptor(ArtifactoryBuilder.class);
def artifactoryCreds = [
username: "admin",
@raphaelcastaneda
raphaelcastaneda / get_plugin_instance.groovy
Created April 15, 2020 18:54
Getting a jenkins plugin by name
def pluginByName = Jenkins.instance.getPluginManager().getPlugin("artifactory");
println "\nFOUND Plugin ${pluginByName.getShortName()} (${pluginByName.getVersion()})"
//println pluginByName.getProperties().toString()
def pluginWrapper = pluginByName.plugin
//println pluginInstance.getProperties().toString()
def myPlugin = this.class.classLoader.loadClass(pluginByName.pluginClass.toString())
println myPlugin.getProperties().toString()
@raphaelcastaneda
raphaelcastaneda / lastpass_cli_helper.sh
Created January 31, 2019 01:49
Bash function to search lastpass cli and put passwords on your clipboard
function getpw() {
if [ $# -lt 1 ]; then
echo "Usage: getpw <LPASS_ENTRY>"
return 1
fi
options=$(lpass ls | egrep -i "$*")
count=$(echo "$options" | wc -l | sed 's/ //g')
if [ $count -gt 1 ]; then
echo "$options"
echo "Too many LastPass entries returned. Please pick from one of the above $count items."

Resizing the primary partition on an Ubuntu machine

So you've added space to a VM but Ubuntu still shows the old size? The partition was created with a certain size, so that new space will just be unallocated until you add it to a partition. You could just add a new partition, but chances are you want the root partition to be bigger, yes?

The steps

Before proceeding, realize that there is a very real possibility that you will lose data if you mess this up. Still here? Cool.

@raphaelcastaneda
raphaelcastaneda / deploy.sh
Last active April 13, 2018 00:58
Setting up portainer on a docker swarm using portainer-endpoint
#! /bin/bash
#export PORTAINER_PASS=#TODO: add me
#export PORTAINER_ENC_PASS=$(docker run --rm httpd:2.4-alpine htpasswd -nbB admin ${PORTAINER_PASS} | cut -d ":" -f 2)
#echo $PORTAINER_PASS | docker secret create portainer_password.v1 --label portainer -
docker stack deploy --compose-file docker-compose.yml portainer
@raphaelcastaneda
raphaelcastaneda / rotary_encoder.py
Created January 9, 2017 08:24
A demo of using a rotary encoder with raspberry pi
import RPi.GPIO as GPIO
import time
# Pin definition
pwm_pin = 18 # adjust brightness for signal
led_pin = 23 # blink when switch pressed
clk_pin = 14 # rotary clock
but_pin = 24 # button input
dat_pin = 25 # rotary data input