Skip to content

Instantly share code, notes, and snippets.

View thbar's full-sized avatar

Thibaut Barrère thbar

View GitHub Profile
@thbar
thbar / main.workflow
Created January 14, 2019 08:42 — forked from jhawthorn/main.workflow
GitHub actions workflow for my static site https://github.com/jhawthorn/site-example for more
workflow "Build and deploy on push" {
on = "push"
resolves = [
"Branch master",
"Invalidate cache",
]
}
action "Build" {
uses = "docker://ruby:latest"
@thbar
thbar / phoenix_to_umbrella
Created October 30, 2018 15:59 — forked from emilsoman/phoenix_to_umbrella
How to move an existing phoenix app under an umbrella app
How to convert existing phoenix app to an umbrella app.
https://elixir-lang.slack.com/archives/phoenix/p1472921051000134
chrismccord [10:14 PM]
@alanpeabody yes, it's straightforward
[10:14]
1) mix new my_umbrella --umbrella
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thbar
thbar / Flexible Dockerized Phoenix Deployments.md
Created August 30, 2018 16:42 — forked from jswny/Flexible Dockerized Phoenix Deployments.md
A guide to building and running zero-dependency Phoenix (Elixir) deployments with Docker. Works with Phoenix 1.2 and 1.3.

Prelude

I. Preface and Motivation

This guide was written because I don't particularly enjoy deploying Phoenix (or Elixir for that matter) applications. It's not easy. Primarily, I don't have a lot of money to spend on a nice, fancy VPS so compiling my Phoenix apps on my VPS often isn't an option. For that, we have Distillery releases. However, that requires me to either have a separate server for staging to use as a build server, or to keep a particular version of Erlang installed on my VPS, neither of which sound like great options to me and they all have the possibilities of version mismatches with ERTS. In addition to all this, theres a whole lot of configuration which needs to be done to setup a Phoenix app for deployment, and it's hard to remember.

For that reason, I wanted to use Docker so that all of my deployments would be automated and reproducable. In addition, Docker would allow me to have reproducable builds for my releases. I could build my releases on any machine that I wanted in a contai

function onPageRequest(req, res) {
res.writeHead(200, {
'Content-Type': 'application/json',
"Access-Control-Allow-Origin": "*"
});
res.end(JSON.stringify(
{
@thbar
thbar / ansible-bootstrap-ubuntu-16.04.yml
Created April 25, 2018 13:21 — forked from gwillem/ansible-bootstrap-ubuntu-16.04.yml
Get Ansible to work on bare Ubuntu 16.04 without python 2.7
# Add this snippet to the top of your playbook.
# It will install python2 if missing (but checks first so no expensive repeated apt updates)
# gwillem@gmail.com
- hosts: all
gather_facts: False
tasks:
- name: install python 2
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
@thbar
thbar / gist:f66a28fbeddd84391663451236d30150
Created December 8, 2017 10:34 — forked from n00neimp0rtant/gist:9515611
simple squash without rebase
## within current branch, squashes all commits that are ahead of master down into one
## useful if you merged with upstream in the middle of your commits (rebase could get very ugly if this is the case)
## commit any working changes on branch "mybranchname", then...
git checkout master
git checkout -b mybranchname_temp
git merge --squash mybranchname
git commit -am "Message describing all squashed commits"
git branch -m mybranchname mybranchname_unsquashed
git branch -m mybranchname
@thbar
thbar / wordpress_importer.rb
Created February 14, 2017 13:37 — forked from stammy/wordpress_importer.rb
Import a WordPress database and generate markdown files for Jekyll
# View my Jekyll blog http://paulstamatiou.com and my jekyll migration post http://paulstamatiou.com/how-to-wordpress-to-jekyll/
#
#
# based on the import script by icebreaker, which is based on mojombo's
# https://github.com/mojombo/jekyll/blob/master/lib/jekyll/migrators/wordpress.rb
# https://gist.github.com/303570
# edited to rewrite image URLs to use my CloudFront URL
require 'rubygems'
require 'sequel'
@thbar
thbar / gist:db63116c7d734a565b1161ed0b894949
Created October 6, 2016 12:38 — forked from alehmann/gist:316522
rubyrep / postgres: syncing tables with circular foreign key constraints
psql postgres -c "create database circular_fkeys_left"
psql circular_fkeys_left <<EOS
create table foos(id integer primary key, bar_id integer);
create table bars(id integer primary key, foo_id integer);
insert into foos(id, bar_id) values(1, 5);
insert into bars(id, foo_id) values(5, 1);
alter table foos add constraint bar_fk foreign key(bar_id) references bars;
alter table bars add constraint foo_fk foreign key(foo_id) references foos;
EOS

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps