Skip to content

Instantly share code, notes, and snippets.

View PlugaruT's full-sized avatar
🥔
Doing this and that

Tudor Plugaru PlugaruT

🥔
Doing this and that
View GitHub Profile
Verifying my Blockstack ID is secured with the address 15oca1RKDVnhc49xWA7P4ttqB47pN87Yai https://explorer.blockstack.org/address/15oca1RKDVnhc49xWA7P4ttqB47pN87Yai
#!/usr/bin/python
# coding: utf-8
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import Column, ForeignKey, Integer, String, Sequence, BigInteger
from sqlalchemy.orm import backref, configure_mappers, relationship
from sqlalchemy_continuum import make_versioned, VersioningManager
from sqlalchemy_continuum.transaction import TransactionBase
app = Flask(__name__)
@PlugaruT
PlugaruT / pipe.py
Created June 3, 2016 18:02
Function for running a given command with, or without pipes.
from subprocess import Popen
from subprocess import PIPE
# def run(command):
# '''Run the given command and return its output
# and exit_code'''
# setting parameter shell=True does the same thing, but, security matters
# process = Popen(command.split(), stdout=PIPE, shell=True)
# (output, _status) = process.communicate()
# exit_code = process.wait()
import unittest
default = ["spare", "hello", "pears", "world", "reaps"]
letters = ["abcde", "qwerty", "yuiop", "edcba"]
word_list = ["abba", "aabb", "bbaa", "abbc", "aacc"]
def find_anagrams(list_of_strings, word):
anagrams = []
for w in list_of_strings:
import unittest
import string
def adjacent_digits_product(numb_str, digits_count):
max_number = 1
for i in range(0, len(numb_str) - (digits_count - 1)):
sub_string = numb_str[i:i + digits_count]
product = 1
for digit in sub_string:
### Assignment ###
#
# Your assignment is to implement the
# following function: `find_next_prime`.
# As the name states, given the number `n` the
# function should return the next closest prime.
#
# Examples:
# * `find_next_prime(6)` should return 7.
# * `find_next_prime(10)` should return 11.