Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴
On vacation

Fran Casas franciscoj

🌴
On vacation
View GitHub Profile
@franciscoj
franciscoj / Makefile
Created Apr 17, 2022
Run go test, using grc for colorizing, make and vim-test
View Makefile
# Build the test command allowing to overwrite some of the options.
TEST_FLAGS?=-v -race -count 1 -timeout 3s
TEST_ARGS?=./...
GO_TEST=go test $(TEST_FLAGS)
.PHONY: test
test:
$(GO_TEST) $(TEST_ARGS)
@franciscoj
franciscoj / main.rs
Created Apr 18, 2020
Tail but in aprox 30 lines of Rust
View main.rs
// This is not at all like tail. Will fail in many scenarios but it was funny to write it :)
use std::fs::File;
use std::io::prelude::*;
use std::io::{BufReader, SeekFrom};
use std::thread::sleep;
use std::time::Duration;
fn main() {
let file_name = "some_file.log";
let file = File::open(file_name.clone()).unwrap();
View gist:63004b5eb919e9ef018a0954d07ea622
irb(main):001:0> h = Hash.new([])
=> {}
irb(main):002:0> h[:hello] << :fran
=> [:fran]
irb(main):003:0> h[:hallo] << :andreas
=> [:fran, :andreas]
irb(main):004:0> h
=> {}
irb(main):005:0> h[:asdf]
=> [:fran, :andreas]
View traefik.config.toml
# Config for a dev app with rails + webpacker
[http]
[http.routers]
[http.routers.https-to-webpack-dev-server]
rule = "Host(`domain.dev`) && PathPrefix(`/sockjs-node`)"
service = "webpack-dev-server"
entrypoints = ["https"]
priority = 2
[http.routers.https-to-webpack-dev-server.tls]
@franciscoj
franciscoj / docker-compose.yml
Last active Jun 5, 2021
Docker for local dev reverse proxy
View docker-compose.yml
version: '3'
services:
proxy:
image: traefik:v2.0 # The official Traefik docker image
network_mode: host # Allows traefik to talk to your host machine
ports:
- "80:80"
- "443:443"
- "8080:8080" # The Web UI
volumes:
View no_focus.rb
# If a spec in the suite is marked with focus on the CI it will fail.
RSpec::Matchers.define :have_no_focus do
match { |ex| !ex.metadata[:focus] }
failure_message(&:inspect)
end
RSpec.configure do |config|
config.before(:each) do |example|
@franciscoj
franciscoj / fira-code.conf
Last active Oct 28, 2018
Use Fira Code everywhere as monospace
View fira-code.conf
<!-- ~/.config/fontconfig/fira-code.conf -->
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="pattern">
<test qual="any" name="family"><string>monospace</string></test>
<edit name="family" mode="assign" binding="same"><string>Fira Code</string></edit>
</match>
</fontconfig>
@franciscoj
franciscoj / example.ex
Created Oct 5, 2018
Remove last line feed from multiline string in elixir
View example.ex
content = """
hello!
"""
assert content == "hello!\n"
content = """
hello!\
"""
@franciscoj
franciscoj / unicodeces.vim
Last active Apr 17, 2018
Unicode things for Vim
View unicodeces.vim
" A couple of nice things your vim can use when you're dealing with unicode text.
" Taken from https://stackoverflow.com/questions/16987362/how-to-get-vim-to-highlight-non-ascii-characters
" Highlight all non ascii characters
syntax match nonascii "[^\x00-\xFF]"
highlight nonascii guibg=Red ctermbg=2
" Find any non ascii character
nnoremap <leader>na /[^\x00-\xFF]<CR>
@franciscoj
franciscoj / list-resolution.sh
Created Dec 21, 2017
Get the resolution from a list of images
View list-resolution.sh
for file in *.png; do identify $file | awk '{print $1, $3}'; done