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
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
<template name="createDiscussionForm">
{{> quickForm collection="Discussions" id="createDiscussionForm" type="insert"}}
</template>
@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 / README.md
Last active September 19, 2017 22:33
Deploying Mup to a single server

And then you want to run the following command after deploy:

ssh -i ~/.ssh/mypem.pem username@ip /home/myapp/rebuild-restart-mup-my-app.sh

Or stick it in the Meteor Up post deploy hook:

  hooks: {
    'post.deploy': {
 localCommand: 'ssh -i ~/.ssh/mypem.pem username@ip /home/myapp/rebuild-restart-mup-my-app.sh',
@elie222
elie222 / withClickOutside.tsx
Created January 24, 2019 20:42
HOC for closing an item when clicked outside. Useful for dropdowns and tooltips
import * as React from 'react'
import hoistNonReactStatic from 'hoist-non-react-statics'
import { findDOMNode } from 'react-dom'
export interface WithClickOutsideProps {
close: () => void
containerElement?: React.RefObject<any>
}
const withClickOutside = <P extends WithClickOutsideProps>(
@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'