Skip to content

Instantly share code, notes, and snippets.

@yannski
yannski / Dockerfile
Last active May 5, 2021 09:33
Using docker and docker-compose for Ruby on Rails development with PostgreSQL
FROM ruby:3.0.1
ARG USER_ID
ARG GROUP_ID
RUN addgroup --gid $GROUP_ID user
RUN adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID user
RUN apt-get update -qq
@yannski
yannski / Dockerfile
Last active May 4, 2021 14:40
Using docker and docker-compose for Ruby on Rails development, no database version
FROM ruby:3.0.1
ARG USER_ID
ARG GROUP_ID
RUN addgroup --gid $GROUP_ID user
RUN adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID user
RUN apt-get update -qq
<? echo "Hello World" ?>
version: '2'
services:
web:
build: .
links:
- redis
- webpack
ports:
- 2400:2400
volumes:
//Add this to fetch the SCALINGO_MYSQL_URL
$url = parse_url(getenv("SCALINGO_MYSQL_URL"));
$db['default'] = array(
'dsn' => '',
'hostname' => $url["host"],
'username' => $url["user"],
'password' => $url["pass"],
'database' => substr($url["path"], 1),
'dbdriver' => 'mysqli',
@yannski
yannski / env
Created June 8, 2017 13:02
env file example
DATABASE_URL=mysql2://dbuser:[email protected]/dbuser
DATABASE_URL_TEST=mysql2://dbuser:[email protected]/dbuser
DEFAULT_HOST=localhost:3000
require "sinatra"
get '/' do
html = ""
filenames = Dir.glob("articles/*.txt").sort.reverse
filenames.each{|filename|
html += article_as_html(filename, 100)
}
return layout(html)
end
require "sinatra"
get '/' do
html = ""
filenames = Dir.glob("articles/*.txt").sort.reverse
filenames.each{|filename|
html += article_as_html(filename, 100)
}
return layout(html)
end
require "sinatra"
get '/' do
html = '<html><head><title>Mon blog</title><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous"></head><body>'
html += '<div class="container"><div class="row"><div class="col-12">'
# récupération de la liste des noms de fichiers, triée par ordre alphabétique inverse
filenames = Dir.glob("articles/*.txt").sort.reverse
filenames.each{|filename|
# on lit le contenu du fichier
func LastMinutesTweets() ([]InfluxValue, error) {
queryString := "SELECT SUM('value') FROM 'tweets'"
queryString += " WHERE hashtag = '" + config.E["HASHTAG"] + "'"
queryString += " AND time >= now() - 60m"
queryString += " GROUP BY time(1m) fill(none) ORDER BY time DESC LIMIT 60"
return executeQuery(queryString)
}
func executeQuery(queryString string) ([]InfluxValue, error) {