Skip to content

Instantly share code, notes, and snippets.

Avatar

Iwan Buetti iwan

View GitHub Profile
@iwan
iwan / province.geojson
Last active Feb 18, 2019 — forked from datajournalism-it/province.geojson
Confini amministrativi delle province italiane
View province.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@iwan
iwan / cinque_province_senza_id.geojson
Created Feb 18, 2019
Cinque province italiane (senza id)
View cinque_province_senza_id.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@iwan
iwan / cinque_province.geojson
Last active Feb 18, 2019
Cinque province italiane (con id)
View cinque_province.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@iwan
iwan / prime.ex
Created Jul 9, 2018
Primality test in Elixir - a simple method
View prime.ex
defmodule Prime do
# https://en.wikipedia.org/wiki/Primality_test#Simple_methods
def is_prime(0) do
false
end
def is_prime(1) do
false
end
View excel_columns_convertions.rb
module ExcelColumnsConverions
# convert the column name ("A", "ACB", ...) to an number (1-based)
def excel_col_number(str)
offset = 'A'.ord - 1
str.chars.inject(0){ |x,c| x*26 + c.ord - offset }.to_i
end
# convert the column number to a string ("A", "ACB", ...)
def excel_col_string(number)
@iwan
iwan / rand_string_generator.rb
Created May 23, 2018
Random string generator
View rand_string_generator.rb
def random_string(length=16)
source = ("a".."z").to_a + ("A".."Z").to_a + (0..9).to_a
Array.new(length){|e| source[rand(source.size)]}.join
end
@iwan
iwan / elixir_phoenix_notes.md
Created Apr 4, 2018 — forked from hmans/elixir_phoenix_notes.md
Notes on learning Elixir and Phoenix
View elixir_phoenix_notes.md

Notes on learning Elixir and Phoenix

Just some assorted notes I've made while digging into Phoenix, Elixir and friends. I'm coming from a strong Rails background, so many of these will refer to features from that framework.

Views / Templates

Biggest difference from Rails?

Unlike Rails, where rendering is almost always performed by a template file, the responsibility of rendering a response in Phoenix lies with a view module (that typically corresponds to the current controller module.) This view module will typically offer a whole bunch of render functions (matching different parameters, first and foremost the template name.) Templates (found in web/templates/) will directly compile into such functions.

@iwan
iwan / devise.it.yml
Last active Mar 20, 2018 — forked from epistrephein/devise.it.yml
Italian translation for Devise 3.5
View devise.it.yml
# Italian translation for Devise 4.2
# Date: 2016-08-01
# Author: epistrephein, iwan
# Note: Thanks to xpepper (https://gist.github.com/xpepper/8052632)
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
it:
devise:
confirmations:
confirmed: "Il tuo account è stato correttamente confermato."
@iwan
iwan / devise_invitable.it.yml
Last active Mar 20, 2018
Italian translation for for DeviseInvitable
View devise_invitable.it.yml
it:
devise:
failure:
invited: "Hai un invito in sospeso, accettalo per completare la creazione del tuo account."
invitations:
send_instructions: "Un'email di invito è stata inoltrata a %{email}."
invitation_token_invalid: "Il token di invito fornito non è valido!"
updated: "La tua password è stata impostata correttamente. Ora sei connesso."
updated_not_active: "La tua password è stata impostata correttamente."
no_invitations_remaining: "Non sono più disponibili inviti."
@iwan
iwan / mergia.rb
Created Jan 26, 2018
Script to merge multiple similar .xls file into one
View mergia.rb
require 'spreadsheet' # https://github.com/zdavatz/spreadsheet/blob/master/GUIDE.md
require 'fileutils'
require 'date'
base_path = File.join(Dir.home, "Downloads", "Esito_aste_STOGIT")
input_xls_path = File.join(base_path, "input")
output_xls_path = File.join(base_path, "merged")
class AuctionFile
attr_reader :filepath, :filename, :book
You can’t perform that action at this time.