Skip to content

Instantly share code, notes, and snippets.

View ademar111190's full-sized avatar
Lightning Networking the Bitcoin

Ademar ademar111190

Lightning Networking the Bitcoin
  • CEO of Bitcoin
  • Itatiba
View GitHub Profile
@ademar111190
ademar111190 / Cpf.java
Created April 27, 2016 14:05
A CPF validator for java and Android, CPF is a brazilian document
import java.util.regex.Pattern;
public class Cpf {
private static Pattern PATTERN_GENERIC = Pattern.compile("[0-9]{3}\\.?[0-9]{3}\\.?[0-9]{3}\\-?[0-9]{2}");
private static Pattern PATTERN_NUMBERS = Pattern.compile("(?=^((?!((([0]{11})|([1]{11})|([2]{11})|([3]{11})|([4]{11})|([5]{11})|([6]{11})|([7]{11})|([8]{11})|([9]{11})))).)*$)([0-9]{11})");
public static boolean isValid(String cpf) {
if (cpf != null && PATTERN_GENERIC.matcher(cpf).matches()) {
cpf = cpf.replaceAll("-|\\.", "");
@ademar111190
ademar111190 / levenshtein.kt
Last active May 20, 2025 17:03
Levenshtein Distance algorithm implementation using Kotlin
import kotlin.math.min
fun levenshtein(lhs : CharSequence, rhs : CharSequence) : Int {
if(lhs == rhs) { return 0 }
if(lhs.isEmpty()) { return rhs.length }
if(rhs.isEmpty()) { return lhs.length }
val lhsLength = lhs.length + 1
val rhsLength = rhs.length + 1
@ademar111190
ademar111190 / install-minerd.sh
Last active July 25, 2024 12:01
A helper to mining using Public Pool and cpuminer
#!/bin/sh
pkg upgrade
apt install build-essential
pkg install git
pkg install libjansson
pkg install libcurl
pkg install neovim
git clone https://github.com/pooler/cpuminer.git
cd cpuminer
@ademar111190
ademar111190 / Either.kt
Last active April 22, 2024 11:17
An Either implementation in kotlin
package functional
sealed class Either<L, R> {
abstract fun fold(left: (L) -> Unit, right: (R) -> Unit)
abstract fun <ML> mapLeft(f: (L) -> ML): Either<ML, R>
abstract fun <MR> mapRight(f: (R) -> MR): Either<L, MR>
@ademar111190
ademar111190 / fontsize.dart
Created January 15, 2024 12:45
Font size experiment
class BAT extends StatelessWidget {
final double fontSize;
const BAT({
super.key,
required this.fontSize,
});
@override
Widget build(BuildContext context) {
@ademar111190
ademar111190 / handbreak.sh
Created October 2, 2023 16:57
Reduce the size of a video (handbreak does better)
#!/usr/bin/env bash
filename=$(basename -- "$1")
filename="${filename%.*}"
ffmpeg -i $1 -vcodec libx265 -crf 30 ${filename}-min.mp4
@ademar111190
ademar111190 / reduce.sh
Created September 28, 2023 16:31
Reduce a video file size with ffmpeg
ffmpeg -i input.xyz -vcodec libx265 -crf 30 output.mp4
@ademar111190
ademar111190 / gist:3224223
Created August 1, 2012 06:21
prolog sudoku solver
:- use_module(library(bounds)).
:- use_module(library(clp_distinct)).
suudoku(P) :-
Rows = [R1,R2,R3,R4,R5,R6,R7,R8,R9],
problem(P, Rows),
append_all(Rows, Vars),
vars_in(Vars, 1, 9),
Vars in 1..9,
row_constraint(Rows),
@ademar111190
ademar111190 / AndroidManifest.xml
Created December 3, 2020 11:52
Disable all uses feature
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- region hardware -->
<!-- Audio -->
<uses-feature
android:name="android.hardware.audio.low_latency"
android:required="false" />
<uses-feature
android:name="android.hardware.audio.output"
@ademar111190
ademar111190 / umbrel.dockerfile
Created March 18, 2023 16:07
Just a docker file to create an umbrel distrobox
FROM docker.io/library/ubuntu:22.10
# distrobox stuff
RUN export DEBIAN_FRONTEND=noninteractive; \
apt-get update; \
apt upgrade -y; \
apt-get install -y \
bash \
apt-utils \
bc \