Skip to content

Instantly share code, notes, and snippets.

View neara's full-sized avatar
🏠
Working from home

Ana neara

🏠
Working from home
View GitHub Profile
@neara
neara / forms.py
Last active March 12, 2026 14:13
Django Class Based Views and Inline Formset Example
from django.forms import ModelForm
from django.forms.models import inlineformset_factory
from models import Sponsor, Sponsorship
class SponsorForm(ModelForm):
class Meta:
model = Sponsor
@neara
neara / Procfile
Created April 23, 2014 13:21
Celery Multiple Queues Setup
web: run-program gunicorn arena.wsgi
celery_beat: run-program celery -A arena beat -l info
celery1: run-program celery -A arena worker -Q default -l info --purge -n default_worker
celery2: run-program celery -A arena worker -Q feeds -l info --purge -n feeds_worker
@neara
neara / feeds.py
Created July 28, 2013 08:07
Django RSS feed example
from django.shortcuts import get_object_or_404
from django.contrib.syndication.views import Feed
from django.utils.feedgenerator import Rss201rev2Feed
from myproject.myapp.models import Model, Broadcast, \
BroadcastSocialAccountStatus
OFFICIAL_URL = "http://mainwebsite.com/"
OFFICIAL_LOGO_URL = 'https://s3.amazonaws.com/bucketname/logo.png'

Using Elixir releases and multi-stage Docker files to simplify Phoenix deployment

This repo is my experiment in deploying a basic Phoenix app using the release feature from elixir 1.9 (https://elixir-lang.org/blog/2019/06/24/elixir-v1-9-0-released/) and docker, via a multi-stage Dockerfile (https://docs.docker.com/develop/develop-images/multistage-build/) leveraging bitwalker's docker images for Elixir and Phoenix.

Step 1: Install Elixir 1.9.1 (and Erlang)

The simplest way to manage Elixir versions is to use asdf.

@neara
neara / Elixir Email Validation
Created February 17, 2020 23:05 — forked from mgamini/Elixir Email Validation
Elixir Email Validation
defmodule EmailValidator do
# ensure that the email looks valid
def validate_email(email) when is_binary(email) do
case Regex.run(~r/^[\w.!#$%&’*+\-\/=?\^`{|}~]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$/i, email) do
nil ->
{:error, "Invalid email"}
[email] ->
try do
Regex.run(~r/(\w+)@([\w.]+)/, email) |> validate_email
@neara
neara / python27_37_utils.py
Last active October 3, 2019 19:27
Small utilities that work in python 2.7 and python 3.7+
def batchify(items_list, batch_size=500):
"""Generate batches from items list.
Args:
items_list (list): list that will be batchified.
batch_size (int, default=500): batch size that will be returned.
last batch is not promised to be exactly the length of batch_size.
Returns:
subset of items_list
@neara
neara / Main.elm
Created February 18, 2019 10:13
Elm Tutorial - Forms
import Browser
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput, onClick)
-- MAIN
@neara
neara / generate-ssh-key.sh
Last active February 12, 2019 10:27 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/mozilla_rsa
@neara
neara / clear.txt
Created March 13, 2018 13:26 — forked from EQuimper/clear.txt
React-Native clear Watchman + Cache
watchman watch-del-all && rm -rf node_modules/ && yarn cache clean && yarn install && yarn start -- --reset-cache