Skip to content

Instantly share code, notes, and snippets.

View crossworth's full-sized avatar

Pedro Henrique crossworth

View GitHub Profile
@crossworth
crossworth / customdriver.go
Created January 19, 2022 21:52
Ent custom driver
package customdriver
import (
"context"
"entgo.io/ent/dialect"
)
var _ dialect.Driver = (*CustomDriver)(nil)
@crossworth
crossworth / patch_apk_for_sniffing.md
Created April 9, 2021 17:08 — forked from unoexperto/patch_apk_for_sniffing.md
How to patch Android app to sniff its HTTPS traffic with self-signed certificate

How to patch Android app to sniff its HTTPS traffic with self-signed certificate

  • Download apktool from https://ibotpeaches.github.io/Apktool/
  • Unpack apk file: java -jar /home/expert/work/tools/apktool.jar d net.flixster.android-9.1.3@APK4Fun.com.apk
  • Modify AndroidManifest.xml by adding android:networkSecurityConfig="@xml/network_security_config" attribute to application element.
  • Create file /res/xml/network_security_config.xml with following content:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config>
@crossworth
crossworth / BSTRUtils.java
Created July 11, 2020 21:10
BSTRUtils JNA Java
import com.sun.jna.Memory;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.PointerByReference;
/**
* BSTRUtils faz a conversão do tipo String para BSTR.
* Basicamente BSTR é um tipo de string similar a uma string wide comum em C do *Windows*.
* Basicamente uma string BSTR tem um prefix inteiro de 4bytes informando o tamanho da string
* seguido pela string (cada carácter contendo 2bytes) e para finalizar um null terminator de 2bytes.
* <p>
@crossworth
crossworth / README.md
Created April 6, 2020 23:08 — forked from crgimenes/README.md
Example of pagination using PostgreSQL, Golang and SQLx

Configure environment variable

export DATABASE_URL=postgres://postgres@localhost/dbname?sslmode=disable 

Run in CLI

go run main.go -page 1
@crossworth
crossworth / sort.go
Created March 30, 2020 23:30
sort file by mod time
package main
import (
"fmt"
"path/filepath"
"time"
"sort"
"gopkg.in/djherbis/times.v1"
"os"
)
@crossworth
crossworth / ocaml_lwt_sample.ml
Created February 10, 2020 16:28 — forked from mjambon/ocaml_lwt_sample.ml
OCaml/Lwt crash course. Adult supervision recommended.
(*
Interactive approach
--------------------
You can copy-paste code into `utop`, provided you load the lwt.unix
package:
#use "topfind";;
#require "lwt.unix";;
@crossworth
crossworth / docker_problem.txt
Last active November 4, 2019 17:23
Docker freeze/stuck
com.docker.driver.amd64-linux.log
Not working log:
time="2019-11-04T12:47:37-03:00" level=info msg="Ports are not available: unable to list exposed ports: Get http://unix/forwards/list: net/http: request canceled (Client.Timeout exceeded while awaiting headers)"
time="2019-11-04T12:47:37-03:00" level=info msg="Cancel connection..."
Working log:
time="2019-11-04T13:33:35-03:00" level=info msg="proxy >> GET /forwards/list\n"
The problem is that VPNKit cannot list the ports.
<?php
function dockerGet($endpoint) {
set_time_limit(0);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_UNIX_SOCKET_PATH, '/var/run/docker.sock');
curl_setopt($ch, CURLOPT_BUFFERSIZE, 256);

Install Supervisor with sudo apt-get install supervisor in Unix or brew install supervisor in Mac OSX. Ensure it's started with sudo service supervisor restart in Unix or brew services start supervisor in Mac OSX.

In Unix in /etc/supervisord/conf.d/ create a .conf file. In this example, laravel_queue.conf (contents below). Give it execute permissions: chmod +x laravel_queue.conf.

In Mac OSX first run supervisord -c /usr/local/etc/supervisord.ini and in /usr/local/etc/supervisor.d/ create a .conf file. In this example, laravel_queue.conf (contents below). Give it execute permissions: chmod +x laravel_queue.conf.

This file points at /usr/local/bin/run_queue.sh, so create that file there. Give this execute permissions, too: chmod +x run_queue.sh.

Now update Supervisor with: sudo supervisorctl reread in Unix and with: brew services restart supervisor in MAc OSX . And start using those changes with: sudo supervisorctl update.

@crossworth
crossworth / git-deployment.md
Created February 25, 2018 02:34 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your lokal GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like my Deepl.io to act upon a Web-Hook that's triggered that service.