Skip to content

Instantly share code, notes, and snippets.

View ppcamp's full-sized avatar

Pedro Augusto Campos Dos Santos ppcamp

View GitHub Profile
@ppcamp
ppcamp / save-object-blob.js
Last active May 30, 2024 02:50 — forked from philipstanislaus/gist:c7de1f43b52531001412
Save a blob (object generated in UI) locally as a file
/**
* Saves a Blob object as a file with the specified filename.
*
* @param {Blob} blob - The Blob object to be saved.
* @param {String} filename - The desired filename for the saved file.
* @example
* const foo = `
* NAME;DESCR
* Foo;desc1
* bar;desc2
@ppcamp
ppcamp / common.pl
Created December 29, 2021 14:07
Pack with some functions in PROLOG lang
append([],L,L):-!.
append([H|T1], L, [H|T3]):- append(T1,L,T3).
erase(X,L1,L2):- append(A, [X|D], L1),
append(A, D, L2).
fatorial(0,1):-!.
fatorial(N,F):- N1 is N-1,
fatorial(N1,F1),
F is N*F1.
@ppcamp
ppcamp / state-machine.cpp
Created December 29, 2021 18:39
A simple code that implements a state machine in c++
/**
* A abordagem adotada é a mais próxima do AFD desenvolvido.
* Problemas: Para uma cadeia de chars mt grande pode ocasionar
* em estouro da pilha
*/
#include <iostream>
using namespace std;
bool S1(string, int &);
@ppcamp
ppcamp / sources.list
Created February 12, 2022 14:21 — forked from h0bbel/sources.list
/etc/apt/sources.list for Ubuntu 18.04.1 LTS Bionic Beaver
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
@ppcamp
ppcamp / Makefile
Last active May 8, 2023 14:32
Self documented Makefile with mark support and iddents
default: help
.PHONY: run
.PHONY: help
.PHONY: build
.PHONY: docker
.PHONY: migrate
.PHONY: create_migration
.PHONY: revert_migrations
.PHONY: generate
@ppcamp
ppcamp / go.Dockerfile
Created June 22, 2022 14:56
go multibuild dockerfile
FROM golang:1.18-alpine as builder
RUN mkdir /build
WORKDIR /build
ADD src /build/
RUN apk update && \
apk upgrade && \
apk add --no-cache musl-dev gcc build-base libc-dev ca-certificates wget
@ppcamp
ppcamp / CodeMirrorV6.svelte
Last active November 1, 2022 20:17
CodeMirror v6 simple implementation
<!--
@component
# CodeMirror
A simple CodeMirror implementation that can be used as base for the text editor.
## Args
- **value**: `string` The textarea field
@ppcamp
ppcamp / Find duplicates.md
Last active April 7, 2024 14:43
Find duplicates bash
  • Handmade (tooks way more time)
# Based on
# https://unix.stackexchange.com/questions/277697/whats-the-quickest-way-to-find-duplicated-files
# find all non empty files and prepend each match with a md5 
# (wich may take time, but guarantees that the content is the same, while the name may be different)
find . ! -empty -type f -exec md5sum {} + | \
  # sort using 48 cores
@ppcamp
ppcamp / GREP_PORT_BASH.MD
Created October 25, 2023 18:43
Grep current program using some TCP port
sudo lsof \
  # convert hosts and ports files to the equivalent being accessed
  -nP \
  # grep only the process using that
  -t \
  # grep only port 6060
  -sTCP:LISTEN -iTCP:6060
@ppcamp
ppcamp / godoc_running.MD
Last active October 25, 2023 18:53
Serve Godoc

Acess doc by terminal

go doc PACKAGE_NAME

Godoc string server

First, download it