Skip to content

Instantly share code, notes, and snippets.

View ryanpadilha's full-sized avatar
:octocat:

Ryan Padilha ryanpadilha

:octocat:
View GitHub Profile
@ryanpadilha
ryanpadilha / gist:13114364bc54988fd14136943e19c134
Created February 13, 2019 13:09 — forked from mcxiaoke/gist:b7dcbfdc800b06a5439bb7eb2cd223dd
Returning MySQL query data in a csv file with Flask
## I'm working on a project using Flask to access a database and then
## pass on query data to a client where the data will be graphed
## in the browser.
## I wanted to enable users to retrieve the graph data
## in a csv file after clicking a button on the client.
## This is a generalized version of how I did it:
# imports other than Flask
import csv
from sqlalchemy import create_engine
@ryanpadilha
ryanpadilha / views.py
Created February 13, 2019 13:09 — forked from reinaldons/views.py
Create CSV on-the-fly with Flask, stream_with_context and SQLAlchemy using generator
from datetime import datetime
from flask import current_app, stream_with_context, Response
from flask_blueprint_acquisition import current_blueprint
from sqlalchemy.sql import compiler
from .blueprints import base_blueprint
from .models import Acquisition, Package, Product, User
@ryanpadilha
ryanpadilha / brazilian_phone_mask_with_area_code.js
Created January 6, 2019 00:44 — forked from MauricioMoraes/brazilian_phone_mask_with_area_code.js
Mask for 8 or 9 digit phones in brazilian format with area code (ddd) - Using Jquery.inputmask plugin
// Using jquery.inputmask: https://github.com/RobinHerbots/jquery.inputmask
// For 8 digit phone fields, the mask is like this: (99) 9999-9999
// For 9 digit phone fields the mask is like this: (99) 99999-9999
function setupPhoneMaskOnField(selector){
var inputElement = $(selector)
setCorrectPhoneMask(inputElement);
inputElement.on('input, keyup', function(){
setCorrectPhoneMask(inputElement);
});
@ryanpadilha
ryanpadilha / start-flask-app.sh
Created January 4, 2019 13:25
This script start python application using Gunicorn
#!/bin/bash
# This script start python application using Gunicorn
set -e # if occur any error, exit
function to_console {
echo -e "\n*** $1 ***\n"
}
@ryanpadilha
ryanpadilha / gist:0b54ea13dd000985ecda8bd5590db384
Created September 17, 2018 19:45 — forked from ehuynh/gist:2572398
Start and Stop Jenkins on OSX
# start
sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist
# stop
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
@ryanpadilha
ryanpadilha / Dynamic_Load_On_Scroll_Jquery.html
Created August 17, 2018 14:43 — forked from sphingu/Dynamic_Load_On_Scroll_Jquery.html
Loading content on scroll to bottom on page using Jquery
<html>
<head>
<title>Scroll to bottom Detection</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
var count=0;
$(document).ready(function(){
SetValues();
$(window).scroll(function(){
//Will check if the user has reached bottom of a PAGE
@ryanpadilha
ryanpadilha / .ovpn
Last active August 18, 2018 03:18
OpenVPN scripts for Linux working with Network Manager
#
# OPVN compilation
# -- sudo apt-get install liblzo2-dev
# -- sudo apt-get install libpam0g-dev
#
# OPVN GUI Importer -- sudo apt install network-manager-openvpn-gnome openvpn-systemd-resolved
# configure the .ovpn file, adding last 3 lines in the file.
#
client
@ryanpadilha
ryanpadilha / MultiTenantFlask.py
Created August 6, 2018 18:19 — forked from TonyFrancis/MultiTenantFlask.py
Creating multi Tenant system with multiple Database. Switching between databases based on subdomain related to tenant
from functools import wraps
from flask import Flask, g, session, request, abort, jsonify
from flask_migrate import MigrateCommand, Migrate
from flask_script import Manager
from flask_sqlalchemy import SQLAlchemy
flask_app = Flask(__name__, static_folder='./static')
db = SQLAlchemy()
migrate = Migrate()

Free O'Reilly books and convenient script to just download them.

Thanks /u/FallenAege/ and /u/ShPavel/ from this Reddit post

How to use:

  1. Take the download.sh file and put it into a directory where you want the files to be saved.
  2. cd into the directory and make sure that it has executable permissions (chmod +x download.sh should do it)
  3. Run ./download.sh and wee there it goes. Also if you do not want all the files, just simply comment the ones you do not want.
@ryanpadilha
ryanpadilha / sts.desktop
Created July 12, 2018 14:46
Create desktop entry in Ubuntu to STS
- Create a file with the content below:
[Desktop Entry]
Type=Application
Name=sts
Comment=Spring Tool Suite
Icon=/home/ryan/development/sts-bundle/sts-3.9.5.RELEASE/icon.xpm
Exec=/home/ryan/development/sts-bundle/sts-3.9.5.RELEASE/STS
Terminal=false
Categories=Development;IDE;Java;