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
(define find-char ; value: integer | |
(lambda (str chr) ; str: string; chr: char | |
(let ((last-pos (- (string-length str) 1))) | |
(let ((is-char? (char=? chr (string-ref str last-pos)))) | |
(cond ((= (string-length str) 1) (if is-char? last-pos -1)) | |
(is-char? last-pos) | |
(else (find-char (substring str 0 last-pos) chr))))))) | |
(define rep-sum | |
(lambda (base str exp-num) |
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
(define find-point | |
(lambda (str) | |
(let ((last-pos (- (string-length str) 1))) | |
(let ((point? (char=? #\. (string-ref str last-pos)))) | |
(cond ((= (string-length str) 1) (if point? last-pos -1)) | |
(point? last-pos) | |
(else (find-point (substring str 0 last-pos)))))))) | |
(define binary-sum |
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
(define remainder-to-hex ; val: string | |
(lambda (n) ; n: integer 0 <= n <= 16 | |
(let ((str-offset (lambda (k) (int->string (+ n k))))) | |
(cond ((< n 10) (str-offset 48)) | |
((> n 9) (str-offset 55)) | |
(else "NOTVALID") | |
) | |
) | |
) | |
) |
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
from sqlalchemy import create_engine | |
from sqlalchemy.ext.declarative import declarative_base, DeferredReflection | |
from sqlalchemy.orm import scoped_session, sessionmaker | |
connection_string = << your connection string here >> | |
engine = create_engine(connection_string) | |
db_session = scoped_session(sessionmaker(autocommit=False, | |
autoflush=False, | |
bind=engine)) |
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
from sqlalchemy import Column, Integer, ForeignKey | |
from sqlalchemy.orm import relationship | |
from database import Base | |
class PersonModel(Base): | |
__tablename__ = 'person' | |
uuid = Column(Integer, primary_key=True) | |
Articles = relationship("ArticleModel") | |
class ArticleModel(Base): |
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
import graphene | |
from graphene_sqlalchemy import SQLAlchemyConnectionField, SQLAlchemyObjectType | |
from models import * | |
class Person(SQLAlchemyObjectType): | |
class Meta: | |
model = PersonModel | |
interfaces = (graphene.relay.Node, ) |