Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python3
from tempfile import mkstemp
from shutil import move, copymode
from os import fdopen, remove
import sys
import pdb
filename = sys.argv[-1]
@henrypalacios
henrypalacios / flask_notes.md
Last active September 27, 2019 13:48
My Notes about framework Flask Python 3

Migrations

Flask-Migrate, migrations with Alembic

$ pip install Flask-Migrate

And on our main.py import and add Migrate

from flask_migrate import Migrate
from config import DevConfig
@henrypalacios
henrypalacios / test_runner.py
Created September 11, 2018 20:31
Use file storage on the local filesystem in Django unit tests
import shutil
import tempfile
from django.conf import settings
from django.core.files.storage import FileSystemStorage
from django.db.models import FileField
from django.db.models.loading import get_model, get_models
from django.test.runner import DiscoverRunner
@henrypalacios
henrypalacios / example.com
Created December 5, 2017 04:46 — forked from mignev/example.com
Django deployment with Nginx and Tornado Web
upstream tornadoFrontends {
server 127.0.0.1:8000;
server 127.0.0.1:8001;
server 127.0.0.1:8002;
server 127.0.0.1:8003;
}
server {
listen 80;
# We support all major PHP versions. Please see our documentation for a full list.
# https://documentation.codeship.com/basic/languages-frameworks/php/
# By default we use the latest PHP version from the 5.5 release branch, but Laravel requires at least version 5.6.4
phpenv local 7.0
mysql -e 'create database tests_christian_landing;'
#change in projects settings -> env variables -> add: COMPOSER_HOME | ${HOME}/cache/composer
composer install --prefer-dist --no-interaction
cp .env.codeship .env
php artisan migrate --force
@henrypalacios
henrypalacios / Nielsen2012Python_case.py
Created July 27, 2017 03:36 — forked from fnielsen/Nielsen2012Python_case.py
Text mining example in Python
# $Id: Nielsen2012Python_case.py,v 1.2 2012/09/02 16:55:25 fn Exp $
# Define a url as a Python string (note we are only getting 100 documents)
url = "http://wikilit.referata.com/" + \
"wiki/Special:Ask/" + \
"-5B-5BCategory:Publications-5D-5D/" + \
"-3FHas-20author%3DAuthor(s)/-3FYear/" + \
"-3FPublished-20in/-3FAbstract/-3FHas-20topic%3DTopic(s)/" + \
"-3FHas-20domain%3DDomain(s)/" + \
"format%3D-20csv/limit%3D-20100/offset%3D0"
@henrypalacios
henrypalacios / .sql
Created July 10, 2017 03:48
Create User with root privileges
mysql -u root -p
CREATE USER 'homestead'@'localhost' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'homestead'@'localhost' WITH GRANT OPTION;
CREATE USER 'homestead'@'%' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'homestead'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
@henrypalacios
henrypalacios / uploadtest.php
Created May 24, 2017 03:26 — forked from erikaheidi/uploadtest.php
upload test with silex
<?php
require_once __DIR__.'/vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
$app = new Silex\Application();
$app['debug'] = true;