Skip to content

Instantly share code, notes, and snippets.

View gentildpinto's full-sized avatar

Gentil Pinto gentildpinto

View GitHub Profile
@gentildpinto
gentildpinto / truncatePgSQL.sql
Created January 4, 2025 12:49
Truncate PostgreSQL Database
DO $$
DECLARE
r RECORD;
BEGIN
-- Disable all triggers temporarily
SET session_replication_role = 'replica';
FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = 'public')
LOOP
EXECUTE 'TRUNCATE TABLE ' || quote_ident(r.tablename) || ' CASCADE';
@rodrigomartind
rodrigomartind / SmallDesignToolCompose.kt
Created April 14, 2023 18:53
Small Design Tool in Jetpack Compose
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
@UbadahJ
UbadahJ / FilterableListAdapter.kt
Last active May 5, 2024 02:25
A filterable ListAdapter for RecyclerView
abstract class FilterableListAdapter<T, VH : RecyclerView.ViewHolder>(
diffCallback: DiffUtil.ItemCallback<T>
) : ListAdapter<T, VH>(diffCallback), Filterable {
private var originalList: List<T> = currentList.toList()
override fun getFilter(): Filter {
return object : Filter() {
override fun performFiltering(constraint: CharSequence?): FilterResults {
return FilterResults().apply {
@gentildpinto
gentildpinto / UserController.php
Created January 30, 2021 21:20
A simple code to get the next auto increment id from a table in laravel
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
class UserController extends Controller
{
/**
* @return mixed
@gentildpinto
gentildpinto / recursive-sum-of-numbers-in-ruby.rb
Last active January 5, 2021 21:51
Algorithm to add numbers recursively with ruby
def sum(*numbers)
return numbers[0] if numbers.length == 1
sum_accumulator = numbers.pop
return sum_accumulator + sum(*numbers)
end
sum(1, 2, 3, 4) # 1 + 2 + 3 + 4 = 10
@prologic
prologic / LearnGoIn5mins.md
Last active May 23, 2025 18:08
Learn Go in ~5mins
package main
import qrcode "github.com/skip2/go-qrcode"
func main() {
q, err := qrcode.New("https://example.org", qrcode.Medium)
if err != nil {
panic(err)
}
@Stunext
Stunext / HandlePutFormData.php
Created November 20, 2018 20:12
Laravel: Middleware to support multipart/form-data in PUT, PATH and DELETE requests
<?php
namespace App\Http\Middleware;
use Closure;
use Symfony\Component\HttpFoundation\ParameterBag;
/**
* @author https://github.com/Stunext
*
@crissilvaeng
crissilvaeng / README.md
Created May 9, 2016 19:40
Padrão e mensagens de commit.

Styleguides

Mensagens de commit styleguide

  • Usar modo imperativo ("Adiciona feature" não "Adicionando feature" ou "Adicionada feature")
  • Primeira linha deve ter no máximo 72 caracteres
  • Considere descrever com detalhes no corpo do commit
  • Considere usar um emoji no início da mensagem de commit

Emoji | Code | Commit Type