Skip to content

Instantly share code, notes, and snippets.

View pedroxs's full-sized avatar

Joaquim Pedro Silveira pedroxs

View GitHub Profile
@kipcole9
kipcole9 / function_clause.ex
Created October 23, 2019 11:04
Debug Elixir Function Clause errors
defmodule FunctionClause do
@moduledoc """
Format function clauses using Exception.blame/3
"""
@doc """
Given a `module`, `function`, and `args` see
if that function clause would match or not match.
This is useful for helping diagnose function
@FGRibreau
FGRibreau / 1_stripe-schema.md
Last active February 5, 2025 04:18
Stripe database schema (extracted from their sigma product) as of 2019-10-09
jqn -r markdown-table 'map(x => "## " + x.name + "\n\n" + markdownTable(x.columns.map(y => [y.name, y.type]))  ) | join("\n\n")' < /tmp/stripe.json

accounts

id varchar
business_name varchar
business_url varchar
@sgyyz
sgyyz / uao.md
Last active May 3, 2024 14:15
uao command - unzip your project and import to intellij automatically
  1. import project into idea command
$ curl -L "https://gist.githubusercontent.com/chrisdarroch/7018927/raw/9a6d663fd7a52aa76a943fe8a9bc6091ad06b18d/idea" -o /usr/local/bin/idea
$ chmod +x /usr/local/bin/idea
  1. unzip and open project command
$ curl -L "https://gist.githubusercontent.com/sgyyz/adfa4f05af3d81cf0e17e19cf7044c85/raw/b6b9e871d5a4f5435a09d00b0a52e3db0b90699a/uao.sh" -o /usr/local/bin/uao.sh
$ chmod +x /usr/local/bin/uao.sh
$ ln -sf /usr/local/bin/uao.sh /usr/local/bin/uao
@ggviana
ggviana / VAAS - Vampeta as a Service
Last active March 15, 2019 09:19
VAAS - Creates a POSITIVE office culture of locking computer when leaving the desk. Complying with the PCI and general security advices.
#!/env/sh
curl -o ~/vamp.jpg 'https://user-images.githubusercontent.com/1886249/45969935-8e566500-c00b-11e8-8821-45a4796048fc.jpeg'
sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "update data set value = '~/vamp.jpg'"
killall Dock
@pedroxs
pedroxs / script-console.groovy
Created August 29, 2017 18:39
Running shell commands with error redirection on Jenkins Script Console
def cmd = "ls -l"
println new ProcessBuilder('sh','-c',cmd).redirectErrorStream(true).start().text
@sdnts
sdnts / example.md
Last active January 10, 2023 20:50
Postman pm.sendRequest example

To send a request via the sandbox, you can use pm.sendRequest.

pm.test("Status code is 200", function () {
    pm.sendRequest('https://postman-echo.com/get', function (err, res) {
        pm.expect(err).to.not.be.ok;
        pm.expect(res).to.have.property('code', 200);
        pm.expect(res).to.have.property('status', 'OK');
    });
});
@noqcks
noqcks / jenkins-plugins.md
Last active January 2, 2024 15:46
How to get a complete plugin list from jenkins (with version)

I need a way to get a list of plugins so that I can use them with docker jenkins in the format <plugin>: <version>

1. get the jenkins cli.

The jenkins CLI will allow us to interact with our jenkins server from the command line. We can get it with a simple curl call.

curl 'localhost:8080/jnlpJars/jenkins-cli.jar' > jenkins-cli.jar
@pedroxs
pedroxs / jq-filters.sh
Last active March 22, 2025 00:02
jq - recursive search for keys containing "string" stripping empty results
# recursive search for keys containing "string" stripping empty results
jq '.. | objects | with_entries(select(.key | contains("ftp"))) | select(. != {})'
# same, but output propper array
jq '[ .. | objects | with_entries(select(.key | contains("ftp"))) | select(. != {}) ]'
# or
jq 'map( .. | objects | with_entries(select(.key | contains("ftp"))) | select(. != {}) )'
# transform input from {type: a, amount: 1} to {a: 1} and sum all values by type
jq '[ .[] | {(.type): .amount} ] | map(to_entries) | add | group_by(.key) | map({key: .[0].key, value: map(.value) | add}) | from_entries'
@pedroxs
pedroxs / CustomEventHandler.java
Last active August 23, 2016 12:17
How to register Hibernate events using JavaConfig so it is possible to use Spring Managed Beans
@Component
public class CustomEventHandler implements PreInsertEventListener, PreUpdateEventListener, PostInsertEventListener, PostUpdateEventListener {
private int someProperty;
@Value("${some-property:20}") // Also possible to use @Autowire if needed =)
public void setSomeProperty(int someProperty) {
this.someProperty = someProperty;
}
@pedroxs
pedroxs / application.yml
Created July 20, 2016 07:44
Spring Boot application properties to check JPA annotations agaisnt created DB model.
---
# Test DB profile
spring:
profiles: db
jpa:
database: MYSQL
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
generate-ddl: true
hibernate:
ddl-auto: create-drop