Skip to content

Instantly share code, notes, and snippets.

View franciscoj's full-sized avatar
🎯
Focusing

Fran Casas franciscoj

🎯
Focusing
View GitHub Profile
@franciscoj
franciscoj / Makefile
Created April 17, 2022 16:47
Run go test, using grc for colorizing, make and vim-test
# 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 / docker-compose.yml
Last active June 5, 2021 18:45
Docker for local dev reverse proxy
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:
@franciscoj
franciscoj / cmyk_to_rgb.rb
Created September 6, 2010 10:42
A way to handle CMYK in your RoR application with paperclip
class User < ActiveRecord::Base
has_attached_file :avatar,
:styles => { :thumbnail => "80x80>", :normalized => "100%" },
:convert_options => { :all => '-strip -colorspace RGB'},
:default_style => :normalized
end
@franciscoj
franciscoj / main.rs
Created April 18, 2020 21:08
Tail but in aprox 30 lines of Rust
// 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();
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]
# 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]
# 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 October 28, 2018 12:01
Use Fira Code everywhere as monospace
<!-- ~/.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 October 5, 2018 08:17
Remove last line feed from multiline string in elixir
content = """
hello!
"""
assert content == "hello!\n"
content = """
hello!\
"""
@franciscoj
franciscoj / unicodeces.vim
Last active April 17, 2018 12:49
Unicode things for 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>