Skip to content

Instantly share code, notes, and snippets.

View elie222's full-sized avatar
🏠
Working from home

Elie Steinbock elie222

🏠
Working from home
View GitHub Profile
<template name="createDiscussionForm">
{{> quickForm collection="Discussions" id="createDiscussionForm" type="insert"}}
</template>
from bottle import route, run, template
def createMagicSquare(n):
magicSquare = [[0]*n for i in range(n)]
# first position
loc = (0, n/2)
for i in range(1, (n*n)+1):
magicSquare[loc[0]][loc[1]] = i
@elie222
elie222 / SubsManager.js
Created November 11, 2016 04:27
SubsManager for React Native Meteor
import Meteor from 'react-native-meteor'
import _ from 'lodash'
import Trackr from 'trackr'
import EJSON from 'ejson'
const SubsManager = function (options) {
const self = this
self.options = options || {}
// maxiumum number of subscriptions are cached
self.options.cacheLimit = self.options.cacheLimit || 10
@elie222
elie222 / apollo.js
Created April 3, 2017 13:47
Meteor Apollo React Native
import ApolloClient from 'apollo-client'
import Settings from './settings'
import { meteorClientConfig } from './meteorApolloClient'
const networkOptions = { uri: Settings.GRAPHQL_URL }
export const client = new ApolloClient(meteorClientConfig(networkOptions))
@elie222
elie222 / Call.tsx
Created February 7, 2019 17:11
Using 'react-responsive-modal' with 'react-confirm'
dialogConfirm('Are you sure you would like to delete this item?', {
title: 'Delete item',
confirmText: 'Delete',
red: true,
}).then(
() => {
// delete item
console.log('delete item')
},
() => {
yarn link # in the root of the forked package
yarn link package-name # in the root of your project
@elie222
elie222 / EditableTitle.tsx
Created February 24, 2019 14:05
Strange span behaviour
import * as React from 'react'
import styled from 'styled-components'
const Container = styled.div<{ light?: boolean }>`
display: inline-block;
/* when using inline-block and overflow: hidden the text rises unless using v align bottom */
vertical-align: bottom;
margin-left: 8px;
font-size: 18px;
max-width: 280px;
@elie222
elie222 / Policy.ts
Created April 10, 2019 22:05
Using TypeORM (MongoDB) and TypeGraphQL together
import { Field, ObjectType, ID } from 'type-graphql'
import {
Entity,
ObjectIdColumn,
ObjectID,
Column,
CreateDateColumn,
UpdateDateColumn,
} from 'typeorm'
@elie222
elie222 / sanctuary.d.ts
Created August 14, 2019 14:28
Sanctuary TS types
declare module 'sanctuary' {
type maybeToNullable<A> = (p: Maybe<A>) => Nullable<A>;
type Nullable<A> = A | null;
type Pair<A, B> = [A, B];
type Thunk<A> = () => A;
type Fn<A, B> = (a: A) => B;
import { Field, ObjectType, ID } from 'type-graphql'
import {
Entity,
ObjectIdColumn,
ObjectID,
Column,
CreateDateColumn,
UpdateDateColumn,
} from 'typeorm'