Skip to content

Instantly share code, notes, and snippets.

View iwan's full-sized avatar

Iwan Buetti iwan

  • Milano, Italy
View GitHub Profile
@iwan
iwan / devise.it.yml
Last active March 20, 2018 20:30 — forked from epistrephein/devise.it.yml
Italian translation for Devise 3.5
# 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 March 20, 2018 20:29
Italian translation for for DeviseInvitable
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 January 26, 2018 15:16
Script to merge multiple similar .xls file into one
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
@iwan
iwan / check_internet_is_reachable.sh
Last active November 13, 2017 15:50
Bash script to check if Internet is reachable (infinity loop)
#!/bin/bash
echo "Started at $(date)"
while true
do
nc -z 8.8.8.8 53 >/dev/null 2>&1
online=$?
if [ $online -eq 0 ]; then
echo "Online"
else
@iwan
iwan / move_files_with_date.rb
Created August 3, 2017 09:15
Ruby script used to move and reorder pdf files with a date in name
require 'fileutils'
require 'byebug'
# What it do
# ============
# It parse the 'dir' directory searching for
# pdf files with name matching the "xxx yyy - 2017-04-16"
# pattern and move them into a date named folder
# (like '2017-04-16')
@iwan
iwan / new.html
Created February 22, 2017 21:41 — forked from mediasota/new.html
Refactor Rails application layout to use HTML5 semantics with HAML
<!DOCTYPE html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset='utf-8'>
@iwan
iwan / 1.yml
Created February 17, 2017 12:40 — forked from ndelitski/1.yml
drone.yml examples
clone:
path: github.com/gogits/gogs
build:
image: golang:$$GO_VERSION
environment:
- TAGS="pam sqlite"
- BUILD_OS="windows linux darwin freebsd openbsd netbsd"
@iwan
iwan / tar_gz_squeeze.rb
Last active April 6, 2016 07:40
Compress all *.json files of a directory using tar and gzip
require 'rubygems/package'
def tar_gz_squeeze(dirname, filename: nil)
filename = filename || dirname
File.open("#{filename}.tar.gz", "wb") do |file|
Zlib::GzipWriter.wrap(file) do |gz|
Gem::Package::TarWriter.new(gz) do |tar|
Dir.glob("#{dirname}/*.json").each do |f|
puts "adding #{File.basename(f)}..."
@iwan
iwan / README.md
Last active March 31, 2016 15:18
Drawing histogram based on table row values

Visualize the magnitude of table row values

The goal is to visualize the magnitude of table row values using histogram bars.

Languages and libraries:

  • html + css
  • coffescript / javascript
  • d3 library

Features:

class Fixnum
def autoref?
a = to_s.rjust(10, "0").split("").map(&:to_i) # a = [2,3,1,1,3,4,5,5,1,9]
h = Hash[(0..9).map{|e| [e, 0]}]
a.each{|e| h[e]+=1}
a.each_with_index do |n, i|
return false if n!=h[i]
end
true
end