Skip to content

Instantly share code, notes, and snippets.

Avatar

Sean Francis N. Ballais seanballais

View GitHub Profile
@seanballais
seanballais / NOTES.txt
Last active Mar 25, 2020
Relevant Files for StackOverflow Question #60835314
View NOTES.txt
- Entity is an alias to, at the moment, a size_t.
- Signature is an alias to an STL bitset.
@seanballais
seanballais / face_detection.py
Last active Jun 6, 2018
Facial Detection Test using face_recognition
View face_detection.py
# The image you will detect faces in must be named 'test.jpg' and
# must reside in the same directory where you placed this script.
#
# Resulting image, where the detected faces are drawn a white rectangle
# over, is saved in the same directory where you placed this script and
# has the file name, 'result.jpeg'.
from PIL import Image, ImageDraw
import face_recognition
import time
@seanballais
seanballais / whole_number_to_roman_numerals.py
Created May 17, 2018
Converts a whole number to roman numberals.
View whole_number_to_roman_numerals.py
import sys
def main():
roman_numerals = {
0: '', 1: 'I', 2: 'II', 3: 'III', 4: 'IV', 5: 'V',
6: 'VI', 7: 'VII', 8: 'VIII', 9: 'IX',
10: 'X', 20: 'XX', 30: 'XXX', 40: 'XL', 50: 'L',
60: 'LX', 70: 'LXX', 80: 'LXXX', 90: 'XC',
100: 'C', 200: 'CC', 300: 'CCC', 400: 'CD', 500: 'D',
View ast-visualization.cube
if (some condition)
var x <- Reachable so I should create a binding to this variable x.
else <- Assume relatively unreachable.
var y <- Unreachable. But I can't be sure if it's reachable (prolly related to Halting Problem?).
So, I must create a binding so that the expressions that operate on y will run without an error and
to take into account cases that this branch is actually reached.
This seems like a waste of memory especially in large codebases.
var z <- Same as above with var y.
@seanballais
seanballais / semiprime_factors.py
Created Apr 28, 2018
Obtaining the Prime Factors of a Semiprime
View semiprime_factors.py
import math
def obtain_pq(n):
p = 0.1
k = math.ceil(math.sqrt(n))
while not p.is_integer():
p = k - math.sqrt((k ** 2) - n)
k += 1
View Pair balance solution.py
def pair_balance(parentheses):
missing_pairs = 0
for parenthesis in parentheses:
if parenthesis == '(':
missing_pairs += 1
elif parenthesis == ')':
if missing_pairs == 0:
return False
missing_pairs -= 1
@seanballais
seanballais / number_palindrome
Created Feb 7, 2018
Generates a number palindrome starting from 1 to a given length.
View number_palindrome
import sys
def horizontal_pyramid(current_value, limit):
if current_value == limit:
return str(current_value)
return str(current_value) + horizontal_pyramid(current_value + 1, limit) + str(current_value)
print(horizontal_pyramid(1, int(sys.argv[1])))
@seanballais
seanballais / HappyIndependenceDay.bf
Created Jul 29, 2015
Prints "Happy Independence Day!"
View HappyIndependenceDay.bf
+++++ +++++ initialize counter (cell #0) to 10
[ use loop to set cell #1 to 60
> +++++ + add 6 to cell #1 (Capital letters)
> +++++ ++++ add 9 to cell #2 (Lowercase letters)
> +++ add 2 to cell #3 to represent space
> + add 1 to cell #4 to represent a new line
<<<< - decrement counter (cell #0)
]
>>>> . go to cell #4 and print a new line
View 99bottlesofbeer.py
def main():
numberOfBottles = 99
while numberOfBottles != 0:
firstVerseLine = getFirstOrLastLine(numberOfBottles)
print(firstVerseLine)
print(firstVerseLine + ", take one down pass it around.")
numberOfBottles = numberOfBottles - 1