Skip to content

Instantly share code, notes, and snippets.

@marciol
marciol / linux-packages
Created April 3, 2024 16:04 — forked from reloxx13/linux-packages
Backup and restore installed packages inside Linux Debian
# Backup your packages list
# Get a packages list
dpkg --get-selections > ~/Package.list
# Copy list of repositories
sudo cp /etc/apt/sources.list ~/sources.list
# Export repo keys
sudo apt-key exportall > ~/Repo.keys
@marciol
marciol / background_job.rs
Created September 8, 2023 15:03 — forked from leandronsp/background_job.rs
A dead simple background job processor written in Rust, using a double-ended queue and primitives sich as Arc and Mutex
use std::sync::{Arc, Mutex};
use std::sync::Condvar;
use std::thread;
use std::collections::HashMap;
use std::time::Duration;
struct Node<T> {
value: T,
next: Option<Arc<Mutex<Node<T>>>>,
previous: Option<Arc<Mutex<Node<T>>>>,
@marciol
marciol / socket.rs
Created September 8, 2023 15:03 — forked from leandronsp/socket.rs
A UNIX socket server written in Rust
// A UNIX socket server written in pure Rust
use std::io::Read;
use std::os::unix::net::{UnixListener, UnixStream};
use std::path::Path;
fn main() {
let socket = Path::new("/tmp/echo.sock");
if socket.exists() {
@marciol
marciol / Application.java
Created March 24, 2023 14:25
Zalando Logbook Request-Response in one line configuration.
package com.acme
import org.zalando.logbook.DefaultHttpLogWriter;
@EnableFeignClients
@SpringBootApplication
public class Application {
@Generated
public static void main( String[] args ) {
FROM hexpm/elixir:1.13.4-erlang-24.3.4.2-debian-stretch-20210902
RUN apt-get update && \
apt-get install -y postgresql-client && \
mix local.hex --force && \
mix local.rebar --force
ENV APP_HOME /app
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
@marciol
marciol / .iex.exs
Created September 14, 2021 23:01
IExWatchTests Utility
Code.compiler_options(ignore_module_conflict: true)
Code.compile_file("~/.iex/iex_watch_tests.exs", File.cwd!())
unless GenServer.whereis(IExWatchTests) do
{:ok, pid} = IExWatchTests.start_link()
# Process will not exit when the iex goes out
Process.unlink(pid)
end
@marciol
marciol / flatten.ex
Created July 23, 2021 03:13
After a long time without working with Elixir, I was studying Clojure and did a implementation of flatten, so I did the same with Elixir.
defmodule Flatten do
def flatten(list, holding_list \\ [], flattened \\ [])
def flatten([[h | t] | rest], holding_list, flattened) do
flatten(h, [t, rest | holding_list], flattened)
end
def flatten([h | t], holding_list, flattened) do
flatten(t, holding_list, [h | flattened])
end
@marciol
marciol / dependencies
Created July 11, 2021 21:37 — forked from mauricioszabo/dependencies
Parallel Consumer Example
[io.confluent.parallelconsumer/parallel-consumer-core "0.3.0.2"]
[fundingcircle/jackdaw "0.8.0"]
@marciol
marciol / sexp-cheat-sheet
Created May 31, 2021 23:58 — forked from dylanmcdiarmid/sexp-cheat-sheet
vim sexp mappings for normal people cheat sheet
.vimrc
" Map leader to comma
let maplocalleader=","
" Toggle this for vim-sexp to not go into insert mode after wrapping something
let g:sexp_insert_after_wrap = 0
" Toggle this to disable automatically creating closing brackets and quotes
let g:sexp_enable_insert_mode_mappings = 1
Vocab
@marciol
marciol / chlorine-config.cljs
Created August 28, 2020 02:24 — forked from mauricioszabo/chlorine-config.cljs
My Chlorine Config
(defn explain-schema []
(p/let [editor-data (editor/get-var)]
(when editor-data
(-> editor-data
(update :text #(str "(if (satisfies? schema.core/Schema " % ") "
"(schema.core/explain " % ")"
"(or #?(:cljs nil :default (:schema (meta (ns-resolve *ns* '" % "))))"
"\"Is not a schema\"))"))
(editor/eval-and-render)))))