Skip to content

Instantly share code, notes, and snippets.

Luca Tironi lucatironi

Block or report user

Report or block lucatironi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lucatironi
lucatironi / README.md
Last active Jan 18, 2018
Docker Compose Jekyll Setup
View README.md

README

docker-compose run --rm web jekyll new --force .
docker-compose up

Open localhost:4000

View bench_fib.rb
require 'benchmark/ips'
def simple_fib(n)
return n if [0, 1].include?(n)
simple_fib(n - 1) + simple_fib(n - 2)
end
def rec_fib(n)
rec = -> (a, b, n) { n == 0 ? a : rec.call(b, a + b, n - 1) }
rec.call(0, 1, n)
View docker-compose.yml
version: '2'
services:
db:
image: mysql:5.7
volumes:
- ./.data/db:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
@lucatironi
lucatironi / server.go
Created Jul 26, 2016
Image placeholder microservice
View server.go
package main
import (
"bytes"
"fmt"
"image"
"image/color"
"image/draw"
"image/jpeg"
"log"
@lucatironi
lucatironi / Dockerfile
Last active Jul 24, 2016
GO Basic Microservice
View Dockerfile
FROM golang:onbuild
EXPOSE 8080
@lucatironi
lucatironi / retrieve_path_in_hash.rb
Created Nov 15, 2014
Retrieve a path in an Hash
View retrieve_path_in_hash.rb
def retrieve(path, hash)
remainder = hash.fetch(path.shift, nil)
remainder.is_a?(Hash) ? retrieve(path, remainder) : remainder
end
path = [:foo, :bar, :baz]
hash = { foo: { bar: { baz: 123 } } }
puts "path: #{path}"
puts "hash: #{hash}"
@lucatironi
lucatironi / list_detail_angularjs.html
Last active Apr 16, 2017
List & Detail View with AngularJS
View list_detail_angularjs.html
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<meta charset="utf-8">
<title>List & Detail View - AngularJS</title>
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<style type="text/css">
.list-group {
max-height: 420px;
overflow-y:scroll;
@lucatironi
lucatironi / fibonacci.rb
Created Sep 28, 2014
Fibonacci Comparison
View fibonacci.rb
# Naive slow implementation
def simple_fib(n)
return n if (0..1).include?(n)
simple_fib(n - 1) + simple_fib(n - 2)
end
# Recursive fast implementation
def rec_fib(n)
rec = -> (a, b, n) { n == 0 ? a : rec.call(b, a + b, n - 1) }
rec.call(0, 1, n)
View HomeActivity.java
package net.primegap.authexample;
import java.io.IOException;
import java.util.ArrayList;
import org.apache.http.client.HttpResponseException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.impl.client.BasicResponseHandler;
View form_spec.rb
require 'spec_helper'
describe Form do
context "ActiveRecord" do
it { should belong_to(:user) }
it { should have_many(:entries) }
it { should validate_presence_of(:mail_to_address) }
it { should validate_presence_of(:redirect_to_url) }
end
You can’t perform that action at this time.