Skip to content

Instantly share code, notes, and snippets.

View namuit's full-sized avatar

Matteo Piotto namuit

View GitHub Profile
@namuit
namuit / index.html
Last active April 19, 2019 15:04
Video player with clickable transcript// source https://jsbin.com/bevehi
<html lang="en">
<head>
<meta charset=utf-8>
<title>Video player with clickable transcript</title>
<style id="jsbin-css">
#all {
background-color: lightgrey;
border-radius:10px;
padding: 20px;
@namuit
namuit / config.yml
Created November 7, 2018 10:43 — forked from Hyperparticle/config.yml
CircleCI 2.0 Jekyll build and Firebase deploy
### Taken from https://github.com/Hyperparticle/hyperparticle.github.io/blob/2365749469b1eea3e8c4b18af24a4865fc426fd3/.circleci/config.yml
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
build:
docker:
@namuit
namuit / contact.rb
Created June 11, 2017 11:21 — forked from endymion/contact.rb
Example of integrating a Ruby on Rails app with Zapier using the REST hooks pattern. With support for triggering the REST hooks from Resque background jobs.
class Contact < ActiveRecord::Base
...
def after_create
if Hook.hooks_exist?('new_contact', self)
Resque.enqueue(Hook, self.class.name, self.id)
# To trigger directly without Resque: Hook.trigger('new_contact', self)
end
end
@namuit
namuit / css-units-best-practices.md
Created December 15, 2016 00:28 — forked from basham/css-units-best-practices.md
CSS Units Best Practices

CSS units

Recommendations of unit types per media type:

Media Recommended Occasional use Infrequent use Not recommended
Screen em, rem, % px ch, ex, vw, vh, vmin, vmax cm, mm, in, pt, pc
Print em, rem, % cm, mm, in, pt, pc ch, ex px, vw, vh, vmin, vmax

Relative units

Relative units

@namuit
namuit / BuildingPhoenixAPI.md
Created November 30, 2016 14:06 — forked from holtbp/BuildingPhoenixAPI.md
Build and test Phoenix JSON API

Build and test a blazing fast JSON API with Phoenix, an Elixir framework

Original Post

Note: This guide was written for Phoenix 1.1.4. Parts of it may no longer work if you are using a newer version.

Let’s build a JSON API that serves a list of contacts. We’ll be writing it using Elixir (version 1.2.5) and Phoenix (version 1.1.4). Phoenix is a framework written in Elixir that aims to make writing fast, low latency web applications as enjoyable as possible.

Source Code: The source code after finishing this guide can be found here.

@namuit
namuit / fastlane-actions-appium.rb
Created April 6, 2016 20:30 — forked from yonekawa/fastlane-actions-appium.rb
Appium support action for fastlane
module Fastlane
module Actions
class AppiumAction < Action
INVOKE_TIMEOUT = 30
APPIUM_PATH_HOMEBREW = '/usr/local/bin/appium'
APPIUM_APP_PATH = '/Applications/Appium.app'
APPIUM_APP_BUNDLE_PATH = 'Contents/Resources/node_modules/.bin/appium'
def self.run(params)
Actions.verify_gem!('rspec')
class DateValidator < ActiveModel::EachValidator
# EXAMPLE
# class UserProfile < ActiveRecord::Base
#
# validates :name, presence: true
# validates :birth_date, presence: true, date: {on_or_after: :birth_date_first, on_or_before: :birth_date_last}
#
# def self.birth_date_first
@namuit
namuit / cf_validator.rb
Created August 25, 2015 14:42
Italian fiscal code validator for Ruby on Rails
class CfValidator < ActiveModel::EachValidator
# Regex for validation. It validates the code without the check-digit.
# It also separates the sections with appropriate grouping. Example:
# codice_fiscale =~ FORMAT_NO_CHECK_DIGIT
# name, year, month, day, place = $1, $2, $3, $4, $5
# Duplication avoidance is handled
FORMAT_NO_CHECK_DIGIT = /([A-Z]{6})([\dL-V]{2})([ABCDEHLMPRST])([\dL-V]{2})([A-Z][\dL-V]{3})/
# Regex for validation. It validates the code with the check-digit
@namuit
namuit / cap_validator.rb
Created August 25, 2015 14:41
Italian Postcode validator for Ruby on Rails
class CapValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
unless value =~ /^(V-|I-)?[0-9]{5}$/
record.errors[attribute] << (options[:message] || "postcode not valid")
end
end
end