Skip to content

Instantly share code, notes, and snippets.

@ssomnoremac
ssomnoremac / roman.js
Last active August 22, 2016 12:25
Convert numbers to Roman numerals
var ROM = [
{key:"M",value:1000},
{key:"D",value:500},
{key:"C",value:100},
{key:"L",value:50},
{key:"X", value:10},
{key:"V",value:5},
{key:"I",value:1}
]
@ssomnoremac
ssomnoremac / registration_page1.js
Last active January 21, 2017 17:34
Example of react-native-row before usage
<View style={{flex:1, flexDirection: 'row'}}>
<View style={Styles.headline}>
<Text style={{fontSize: 17, color: "#fff"}}>Use an Existing Profile:</Text>
<ScrollView>
{ myProfiles.map(this._renderMyProfiles) }
</ScrollView>
</View>
</View>
<Row flex>
<View dial={5}>
<Text fontSize={17} color="#fff">Use an Existing Profile:</Text>
<ScrollView>
{ myProfiles.map(this._renderMyProfiles) }
</ScrollView>
</View>
</Row>
import React from 'react';
import RN from 'react-native';
// http://stackoverflow.com/questions/32947036/how-to-set-font-size-for-different-ios-devices-in-react-native
import { getCorrectFontSizeForScreen } from '../services/Design';
const RNText = RN.Text;
const Platform = RN.Platform;
const FONTS = Platform.OS === 'ios' ? {
'light': 'AvenirNext-Light',
'regular':'AvenirNext-Regular',
@ssomnoremac
ssomnoremac / database.py
Last active May 1, 2018 14:44
database connection for graphene using sqlalchemy
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))
@ssomnoremac
ssomnoremac / models.py
Last active November 17, 2021 17:58
models for graphene sqlalchemy example
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):
@ssomnoremac
ssomnoremac / app.py
Last active April 30, 2018 16:07
app.py for graphene and sqlalchemy
from flask import Flask
from database import db_session
from flask_graphql import GraphQLView
from schema import schema
app = Flask(__name__)
app.debug = True
app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True, context={'session': db_session}))
@ssomnoremac
ssomnoremac / schema.py
Last active May 1, 2018 14:43
schema.py for graphene and sqlalchemy
import graphene
from graphene_sqlalchemy import SQLAlchemyConnectionField, SQLAlchemyObjectType
from models import *
class Person(SQLAlchemyObjectType):
class Meta:
model = PersonModel
interfaces = (graphene.relay.Node, )
@ssomnoremac
ssomnoremac / schema_with_mutation.py
Created March 17, 2017 19:23
mutation example graphene sqlAlchemy
...
class UpdatePersonName(graphene.Mutation):
class Input:
uuid = graphene.Int(required=True)
name = graphene.String(required=True)
person = graphene.Field(Person)
import React from 'react'
import { TextInput, View } from 'react-native'
import defaultTheme from './theme'
const Input = ({inlineLabel}) => (
const styles = {
inlineWrapper: {
flex: inlineLabel ? .5 : 1,
height: inlineLabel ? theme.FormGroup.height - theme.FormGroup.borderWidth*2 : theme.FormGroup.height,