Skip to content

Instantly share code, notes, and snippets.

View hilios's full-sized avatar
🛠️
Breaking stuff

Edson Hilios hilios

🛠️
Breaking stuff
View GitHub Profile
@hilios
hilios / Main.kt
Last active January 13, 2023 17:38
Sudoku solver (kotlin)
import kotlin.time.ExperimentalTime
import kotlin.time.measureTimedValue
@OptIn(ExperimentalTime::class)
fun main() {
val empty = listOf(
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
@hilios
hilios / .vimrc
Last active June 3, 2026 10:20
My Zshell config
set number
set linebreak
set showbreak=+++
set textwidth=100
set showmatch
set spell
set visualbell
set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
set list
@hilios
hilios / Hasher.scala
Last active June 27, 2019 20:04
Simple HMAC 236 hasher
import cats.data.Kleisli
import cats.effect.Sync
import com.google.common.io.BaseEncoding
import javax.crypto.spec.{IvParameterSpec, PBEKeySpec, SecretKeySpec}
import javax.crypto.{Cipher, SecretKeyFactory}
object Hasher {
type Key = (String, String)
final case class InvalidInputException(hash: String, ex: Throwable) extends IllegalArgumentException(s"Could not decrypt [$hash]", ex)
@hilios
hilios / Dockerfile
Created June 4, 2019 22:34
Let's Encrypt docker
FROM ubuntu:18.04
EXPOSE 80 443
COPY ./credentials.json /etc/credentials.json
RUN apt-get update \
&& apt-get install -y --no-install-recommends python-setuptools python-pip certbot lighttpd \
&& pip install -U --no-cache-dir pip certbot certbot-dns-google \
&& chmod a+rwx,u-x,g-rwx,o-rwx /etc/credentials.json \
@hilios
hilios / FutureConcurrentEffect.scala
Last active April 2, 2019 14:44
Effect[Future]
import scala.concurrent.{Await, ExecutionContext, Future, Promise}
import cats.implicits._
import scala.concurrent.duration.Duration
import scala.util.{Failure, Success}
final case class FutureConcurrentEffect()(implicit ec: ExecutionContext) extends FutureEffect with ConcurrentEffect[Future] {
def start[A](fa: Future[A]): Future[Fiber[Future, A]] = Future.successful {
FutureFiber(fa)
}
"""
Get the docker --name from inside a container.
$ pip install docker
"""
import docker
import subprocess
client = docker.from_env()
@hilios
hilios / HowToOTG.md
Created November 16, 2016 01:24 — forked from gbaman/HowToOTG.md
Simple guide for setting up OTG modes on the Raspberry Pi Zero

Raspberry Pi Zero OTG Mode

Simple guide for setting up OTG modes on the Raspberry Pi Zero - By Andrew Mulholland (gbaman).

The Raspberry Pi Zero (and model A and A+) support USB On The Go, given the processor is connected directly to the USB port, unlike on the B, B+ or Pi 2 B, which goes via a USB hub.
Because of this, if setup to, the Pi can act as a USB slave instead, providing virtual serial (a terminal), virtual ethernet, virtual mass storage device (pendrive) or even other virtual devices like HID, MIDI, or act as a virtual webcam!
It is important to note that, although the model A and A+ can support being a USB slave, they are missing the ID pin (is tied to ground internally) so are unable to dynamically switch between USB master/slave mode. As such, they default to USB master mode. There is no easy way to change this right now.
It is also important to note, that a USB to UART serial adapter is not needed for any of these guides, as may be documented elsewhere across the int

@hilios
hilios / Dockerfile
Last active August 29, 2015 14:26
Build mosquitto from source for Docker
FROM debian:jessie
MAINTAINER Edson Hilios <edson.hilios.com.br>
RUN apt-get update -y
RUN apt-get install -y wget
# Install libwebsockets
RUN apt-get install -y cmake libssl-dev
RUN mkdir -p /build/libwebsockets
WORKDIR /build/libwebsockets

How to set a fix IP in Intel Edsion

Edit the file /etc/wpa_supplicant/wpa_cli-actions.sh around the line 50.

$ vim /etc/wpa_supplicant/wpa_cli-actions.sh

Close to the line 50 change it to this.

@hilios
hilios / nginx.ini
Last active August 29, 2015 14:23
Nginx Systemd
[Unit]
Description=Nginx Docker Container
After=docker.service
Requires=docker.service
[Service]
TimeoutStartSec=0
ExecStartPre=-/usr/bin/docker kill %n
ExecStartPre=-/usr/bin/docker rm %n
ExecStartPre=/usr/bin/docker run --name %n -d -p 80:80 -p 443:443 -v /etc/nginx:/etc/nginx -v /var/nginx/html:/usr/share/nginx/html nginx