This file contains hidden or 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
// args | |
// questionId, selectedChoiceId | |
const question = await Question.findById(id); | |
// search if questionId is exist | |
if(question.answers.filter( answer => answer.questionId === questionId ).length === 0){ | |
question.answers.push({ questionId, selectedChoiceId }); | |
} else { |
This file contains hidden or 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
new Resolver({ | |
resolve: async () => { | |
return new Promise((rs, rj) => { | |
Model.find({ _id }, function(err, result){ | |
rs(result); | |
}); | |
}) |
This file contains hidden or 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
// Batch image resizing with Node Imagemagick | |
// author: Rungsikorn Rungsikavanich | |
// contact: [email protected] | |
// Dependencies ( Need native imagemagick ) | |
// $ brew install imagemagick | |
// $ npm i imagemagick lodash | |
// example: `$ DIR=../static/images/stock/herbarium-original node ./lib/batch-resizer.js` | |
// result image will be locate in ./resize folder | |
const im = require('imagemagick'); |
This file contains hidden or 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
export type WorkPlace = { | |
id:string | |
viewCount:number | |
participant:{ | |
male:number | |
female:number | |
ages:number[] | |
} | |
getAverageAges: ()=> number; |
This file contains hidden or 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
// @flow | |
import React from 'react'; | |
import { Textfit } from 'react-textfit'; | |
import _ from 'lodash'; | |
import { TweenMax, Back, Power4 } from 'gsap'; | |
import type { Song } from '../models'; | |
import styles from './SongList.css'; | |
export class PlayerSongList extends React.Component { |
This file contains hidden or 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
.container { | |
background: black; | |
display: flex; | |
flex-direction: column; | |
position: relative; | |
height: 100vh; | |
align-items: center; | |
justify-content: center; | |
box-sizing: border-box; | |
color: #f5f6f8; |
This file contains hidden or 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 React from 'react' | |
import { ApolloProvider, getDataFromTree } from 'react-apollo' | |
import 'isomorphic-fetch' | |
import { sessionQuery } from './withSession' | |
import apolloClientFactory from '../../common/apolloClientFactory' | |
export default (Component) => class withData extends React.Component { | |
static async getInitialProps (context) { | |
if (typeof window === 'undefined') { | |
const props = { | |
user: context.req.user, |
This file contains hidden or 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
graphqlExpress(req => { | |
const extendContext = require('./graphql').getGraphQLExtendedContext(req) | |
// } | |
return ({ | |
schema, | |
tracing, | |
context: { | |
...req, | |
...extendContext | |
}, |
This file contains hidden or 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
const rawSchema = { | |
typeDefs: ` | |
type Query { | |
gqlTools: String | |
} | |
`, | |
resolvers: { | |
Query: { | |
gqlTools: () => 'Hi from gqlTools' | |
} |
This file contains hidden or 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
const momentTimeZone = require('moment-timezone'); | |
function getBKKTime() { | |
const date = new Date() | |
const UTCDateString = date.toISOString() | |
const BKKDateString = moment.tz(UTCDateString, 'Asia/Bangkok').format() | |
return BKKDateString; | |
} |
OlderNewer