Skip to content

Instantly share code, notes, and snippets.

@fisadev
fisadev / put_inside_config.fish
Last active February 25, 2021 03:38
Automagic venv for fish
# usage:
# e --> create and/or activate a virtualenv, named in a way that's unique and related to the current folder
# but stored under ~/venvs/
# e NAME --> create and/or activate a virtualenv with the specified name, stored under ~/venvs/
# you should replace `\/home\/fisa\/devel\/` (scaped text for `/home/fisa/devel/`) with the folder in which most
# of your projects live, so a venv for a project /home/fisa/devel/company_x/project_y/ will be named just
# "company_x_project_y", without the full path as part of the name. It's kind of a default prefix.
function e
@fisadev
fisadev / ssl_and_domains.md
Created May 12, 2020 16:38
Bug in GithubPages for HTTPS and custom domains

Hi!

In 2018 Github Pages announced support for custom domains with HTTPS: https://github.blog/2018-05-01-github-pages-custom-domains-https/

This meant that Github had to generate certs which pointed to the custom domains the users were configuring for their pages. This worked perfectly until a few weeks ago, when all certs started to point to the default domains instead of the custom domains.

That bug breaks all the Github Pages that were using custom domains and HTTPS, because most browsers (Chrome, Firefox, Safari) now block access via HTTPS, warning the users that the sites are insecure and could steal info, etc.

# based on the permission_required decorator, from django.contrib.auth
from django.contrib.auth.decorators import user_passes_test
from django.core.exceptions import PermissionDenied
def group_required(group_name, login_url=None, raise_exception=False):
"""
Decorator for views that checks whether a user belongs to a particular
group, redirecting to the log-in page if necessary.
If the raise_exception parameter is given the PermissionDenied exception
@fisadev
fisadev / work
Created December 3, 2015 14:57
A python script to launch my tmux things at once
#!/usr/bin/env python
# coding: utf-8
from os import system
PROJECT_PATH = 'path_to_your_project'
ACTIVATE_VENV = '. path_to_your_virtualenv/bin/activate'
def tmux(command):
@fisadev
fisadev / .offlineimaprc
Last active August 29, 2015 14:27
Backup automático de gmail
[general]
accounts = GMail
maxsyncaccounts = 3
[Account GMail]
localrepository = Local
remoterepository = Remote
autorefresh = 5
quick = 5
@fisadev
fisadev / keybase.md
Last active September 1, 2016 15:30

Keybase proof

I hereby claim:

  • I am fisadev on github.
  • I am fisadev (https://keybase.io/fisadev) on keybase.
  • I have a public key ASACr4B1E9t_KTdx562nHWZHfyyZxlthCjtbyyeArEtNjAo

To claim this, I am signing this object:

@fisadev
fisadev / sse.py
Created June 25, 2013 17:59
flask simple SSE example
# python (flask) side:
import time
from flask import Response
app = Flask(__name__)
@app.route('/event_stream')
def stream():
def event_stream():