Skip to content

Instantly share code, notes, and snippets.

@lozadaOmr
lozadaOmr / toplog.sh
Last active October 6, 2015 13:48
Pipe top command output to a gzip file
#!/bin/bash
/usr/bin/top -b -n 1 | gzip -c > ~/core_top_logs/$(date +"%Y-%m-%dT%H:%M:%S").gz
# Maybe just use /send endpoint
# Since we dont want to break stuff use different we use route
@app.route('/reset_password', methods=['GET', 'POST'])
def reset_password():
# Create message container - the correct MIME type is
# multipart/alternative.
msg = MIMEMultipart('alternative')
msg['Subject'] = "Link"
# Create the body of the message (a plain-text and an HTML version).
@app.route('/api/help', methods = ['GET'])
def help():
    """Print available functions."""
    func_list = {}
    for rule in app.url_map.iter_rules():
        if rule.endpoint != 'static':
            func_list[rule.rule] = app.view_functions[rule.endpoint].__doc__

return jsonify(func_list)

@lozadaOmr
lozadaOmr / Blade & Jinja.md
Last active August 29, 2015 14:19
Some notes on learning Jinja Template; making a note on its equivalent to Blade

Extending a master template

Jinja - {% extends "base.html" %}
Blade - @extends('templates.blade')

Including a section

Jinja - {% include 'navigation.html' %}
Blade - @include('navigation')

@lozadaOmr
lozadaOmr / Flask Jinja2 Notes.md
Last active August 29, 2015 14:18
some notes taken trying to learn Flask - Python

Render Templates

from flask import render_template
from app import app

@app.route('/')
@app.route('/index')
def index():
    user = {'nickname': 'Miguel'}  # fake user

Install virtualenv

sudo apt-get install python-virtualenv

To activate virtualenv

 virtualenv flask

Install Flask (activate virtualenv first)

pip install Flask
@lozadaOmr
lozadaOmr / .vimrc
Last active August 29, 2015 14:17 — forked from JeffreyWay/.vimrc
set nocompatible " Disable vi-compatibility
set t_Co=256
colorscheme xoria256
set guifont=menlo\ for\ powerline:h16
set guioptions-=T " Removes top toolbar
set guioptions-=r " Removes right hand scroll bar
set go-=L " Removes left hand scroll bar
set linespace=15
* -A in SSH enables agent forwarding.
* -p 2122 is not needed if you use the default port of 22.
* Replace SSH_USER and example.com with your own values.
* Example run: $ envoy run deploy_demo
* --no-scripts because Laravel composer.json's post-install-cmd includes optimize, which is already done by php artisan dump-autoload
@servers(['test' => '-A -p 2122 -l user test.example.com', 'prod' => '-A -p 2122 -l user example.com'])
@task('install_test', ['on' => ['test']])
cd project
@lozadaOmr
lozadaOmr / Laravel Dot Env Variables.md
Last active August 29, 2015 14:17
Alternative to storing pasword or other sensitve data

Question:

Should we include passwords (Database, SSH, etc) on our git repo.

Answer:

Yes, if you don't want to be changing this AKA consistent throughout every other dev.

No, because now everyone will know them

{{-- Define all our servers --}}
@servers(['staging' => '', 'production' => ''])
@setup
{{-- The timezone your servers run in --}}
$timezone = 'Europe/Amsterdam';
{{-- The base path where your deployments are sitting --}}
$path = '/var/www/site.com/htdocs';