Skip to content

Instantly share code, notes, and snippets.

@sousatg
sousatg / app.py
Created November 10, 2022 23:22
Flask App that uses a Logstash TCP Logger
from flask import Flask
from flask import jsonify
from flask import request
from flask_cors import CORS, cross_origin
import socket
TCP_IP = '127.0.0.1'
TCP_PORT = 5959
BUFFER_SIZE = 20
@sousatg
sousatg / Dockerfile
Last active October 30, 2018 23:28
Docker to run PHP scripts
FROM php:5.6-fpm
RUN apt update && apt install -y git zlib1g-dev
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
WORKDIR /app
@sousatg
sousatg / 3DPP.md
Last active July 30, 2018 14:55
Three Day Project Paradigm Outline

Preparation

  • Need a project idea, e.g., web crawler

Day 1

  • Mess around, learn language

Day 2

  • Complete functionality
  • Refactor
  • Eliminate bugs (bug-free by EOD)
@sousatg
sousatg / introrx.md
Created May 3, 2018 09:55 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@sousatg
sousatg / gulpfile.js
Created November 30, 2017 09:56
Gulp wordpress development configuration
const gulp = require('gulp');
const browserSync = require('browser-sync').create();
const sass = require('gulp-sass');
gulp.task('serve', ['sass'], function() {
browserSync.init({
proxy: 'mood.dev'
});
gulp.watch('sass/**/*.scss', ['sass']);
@sousatg
sousatg / README.md
Created October 11, 2017 14:20 — forked from chadrien/README.md
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# http://assicanti.pt/category/uptec/
import PyPDF2
import re
from itertools import takewhile
@sousatg
sousatg / app.py
Created August 10, 2017 16:49
Flask App
import sys
from pprint import pprint
import wtforms_json
from flask import Flask, g, request, redirect, url_for
from flask_marshmallow import Marshmallow
from flask_restful import Resource, Api
from flask_sqlalchemy import SQLAlchemy
from flask_wtf import FlaskForm
@sousatg
sousatg / README.md
Created July 13, 2017 20:47 — forked from tjamps/README.md
Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

The API we are creating in this gist will follow these rules :

  • The API only returns JSON responses
  • All API routes require authentication
  • Authentication is handled via OAuth2 with password Grant Type only (no need for Authorization pages and such).
  • API versioning is managed via a subdomain (e.g. v1.api.example.com)

The API will be written in PHP with the Symfony 2 framework. The following SF2 bundles are used :

@sousatg
sousatg / notas
Created June 16, 2017 10:50
Notas Magento2
Set the magento permissions
find . -type d -exec chmod 755 {} \; && find . -type f -exec chmod 644 {} \; && chmod u+x bin/magento