This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################# | |
# Validate Args # | |
################# | |
if [ "$#" -ne 2 ]; then | |
echo "Usage: $0 FQDN EMAIL" | |
exit 1 | |
fi | |
# Postfix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Example: | |
>>> csv = Csv() | |
>>> csv('127.0.0.1, .localhost, .herokuapp.com') | |
['127.0.0.1', '.localhost', '.herokuapp.com'] | |
>>> csv = Csv(int) | |
>>> csv('1,2,3,4,5') | |
[1, 2, 3, 4, 5] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Generate PDF reports from data included in several Pandas DataFrames | |
From pbpython.com | |
""" | |
from __future__ import print_function | |
import pandas as pd | |
import numpy as np | |
import argparse | |
from jinja2 import Environment, FileSystemLoader | |
from weasyprint import HTML |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
""" | |
Hackish Script to import MyFinance data into GNUCash | |
The order of things: | |
1) Load and Fix the MyFinance dataset | |
2) Separete the data into intermediary parts. | |
3) Define GNUCash helper function. | |
4) Define conversion highlevel functions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def happy(number): | |
string = str(number) | |
digits = [int(char) for char in string] | |
squares = [digit**2 for digit in digits] | |
n = sum(squares) | |
if n >= 10: | |
return happy(n) | |
if n in (1, 7): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Exemplo com closure | |
def crazy_sum(): | |
acc = 0 | |
def wrapped(t): | |
nonlocal acc | |
sum_with_acc = sum(t) + acc | |
acc = max(0, sum_with_acc - 9) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main(): | |
deck = Deck() | |
assert deck | |
assert len(deck) == 52 | |
assert Card(rank='2', suit='spades') == Card(rank='2', suit='spades') | |
assert deck[0] == Card(rank='2', suit='spades') | |
assert deck[:2] == [Card('2', 'spades'), Card('3', 'spades')] | |
assert deck[12::13] == [Card('A', 'spades'), Card('A', 'diamonds'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main(): | |
assert Vector(2, 4) | |
assert (Vector(2, 4).x, Vector(2, 4).y) == (2, 4) | |
assert repr(Vector(2, 4)) == 'Vector(2, 4)' | |
assert str(Vector(2, 4)) == '(2, 4)' | |
assert Vector(2, 4) == Vector(2, 4) | |
assert Vector(2, 4) + Vector(1, 2) == Vector(3, 6) | |
assert Vector(2, 4) * 2 == Vector(4, 8) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python -tt | |
import argparse | |
from collections import Counter | |
import re | |
def purge(word): | |
if not word.isalpha(): | |
word = ''.join(ch for ch in word if ch.isalpha()) | |
return word |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb | |
index cba8e59..af53ec2 100644 | |
--- a/app/controllers/issues_controller.rb | |
+++ b/app/controllers/issues_controller.rb | |
@@ -139,6 +139,7 @@ class IssuesController < ApplicationController | |
if request.get? || request.xhr? | |
@issue.start_date ||= Date.today | |
+ @issue.inspire_on(params[:inspire_on]) if params[:inspire_on] | |
else |
OlderNewer