Skip to content

Instantly share code, notes, and snippets.

View fnando's full-sized avatar

Nando Vieira fnando

View GitHub Profile
@fnando
fnando / ddns.rb
Created April 1, 2022 15:45
Dynamic DNS with DNSimple and Ruby
# frozen_string_literal: true
require "net/http"
require "json"
module Net
def HTTP.patch(url, data, header = nil)
start(url.hostname, url.port, use_ssl: url.scheme == "https") do |http|
http.patch(url, data, header)
end
@fnando
fnando / aspect_ratio.rb
Last active December 5, 2021 05:39
Simplistic approach to calculate image aspect ratio
# frozen_string_literal: true
class AspectRatio
attr_reader :width, :height
def initialize(width, height)
@width = width
@height = height
end
@fnando
fnando / Gemfile
Created September 16, 2021 23:00
Script to remove all travis-ci hooks from Github repos
# frozen_string_literal: true
source "https://rubygems.org"
gem "octokit"
gem "pry-meta"
@fnando
fnando / index.js
Last active September 7, 2020 20:56
Loading Stimulus.js controllers without `@stimulus/webpack-helpers` (no `_controller` suffix, no need to default export classes)
import { Application } from "stimulus";
import "style/main.css";
const application = Application.start();
const context = require.context("./controllers", true, /\.[jt]s$/);
// Let's not follow stimulus' default name pattern.
// Instead, files can be named just as the controller. E.g. if your controller
// is called `RefreshPanel`, your source file would be
@fnando
fnando / disposable.json
Created April 3, 2019 19:41
List of disposable email providers
[
"0-attorney.com",
"0-mail.com",
"00.msk.ru",
"000777.info",
"000invaliddomain.local",
"001.igg.biz",
"0033.pl",
"0039.cf",
"0039.ga",
@fnando
fnando / README.md
Last active April 20, 2022 19:54
HP P1109w: changing wifi settings

HP P1109w: Changing wifi settings

Requirements

Make sure you have httpie installed. If you're using homebrew, you can easily do it so with:

brew install httpie
### Keybase proof
I hereby claim:
* I am fnando on github.
* I am fnando (https://keybase.io/fnando) on keybase.
* I have a public key whose fingerprint is 36A1 2E23 89B8 0492 BF21 2455 C795 5F62 D061 15A5
To claim this, I am signing this object:
@fnando
fnando / README.md
Last active January 3, 2016 08:19
Render templates outside the controller in a Rails app

You templates must live in app/views, as usual. To render it, just use something like below.

Renderer.render(template: "message", locals: {name: "John Doe"});

How to remove <select> dropdown's arrow in Firefox

As this bug report states, there is an issue regarding Firefox's -moz-appearance and <select> elements: it was supposed to ditch the <select>'s arrow (like Chrome's implementation) but it simply doesn't. People were raging about the subject all over the internetz.

Until now.

I figured out a clever workaround to make it work on Firefox. Here is how to do it:

  1. Set -moz-appearance to none. This will "reset" the styling of the element;
.course {
background-repeat: no-repeat;
background-position: 510px center;
}
.course.ruby-on-rails {
background-image: image-url("ruby-on-rails.svg");
}
.no-svg .course.ruby-on-rails {
background-image: image-url("ruby-on-rails.png");
}