Skip to content

Instantly share code, notes, and snippets.

View zapkub's full-sized avatar
🦄
Doing FINE !

Rungsikorn Rungsikavanich zapkub

🦄
Doing FINE !
View GitHub Profile
// @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 {
export type WorkPlace = {
id:string
viewCount:number
participant:{
male:number
female:number
ages:number[]
}
getAverageAges: ()=> number;
@zapkub
zapkub / batch-resizer.js
Last active April 16, 2017 10:05
node imagemagick batch resizing multithread
// 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');
new Resolver({
resolve: async () => {
return new Promise((rs, rj) => {
Model.find({ _id }, function(err, result){
rs(result);
});
})
// 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 {