Skip to content

Instantly share code, notes, and snippets.

View chj1768's full-sized avatar

최현지 chj1768

  • Seoul, south korea
View GitHub Profile
@chj1768
chj1768 / App.jsx
Created August 10, 2017 05:33
how to use redux in react and react-router(2.8.1)
import React from 'react';
import { connect } from 'react-redux';
import { Header } from './Header.jsx';
import { Footer } from './Footer.jsx';
class AppComponent extends React.Component {
constructor( props ) {
super( props );
@chj1768
chj1768 / ErrorMixins.jsx
Created July 3, 2017 08:39
how to use mixin, publish&subscribe(meteor) in React es6
export const ErrorMixins = {
bye() {
console.log('bye');
}
};
@chj1768
chj1768 / ex.js
Last active July 3, 2017 08:23
send email with attachments using meteor.js
Meteor.methods({
sendMail( from, to, userName, attachments ) {
check( from, String );
check( to, String );
check( userName, String );
check( attachments, Array );
this.unblock();
const files = attachments.map( _ => { return { filename : 'filename', path : 'remote file url' }; } ); //example
@chj1768
chj1768 / simple_rsa
Last active December 16, 2022 07:20
RSA encryption / decryption example (nodejs)
openssl key pair generate
//client - using meteor.js
const nodersa = Npm.require('node-rsa');
import { HTTP } from 'meteor/http';
const syncPost = Meteor.wrapAsync( HTTP.post, HTTP );
encryptStringWithRsaPublicKey( data ) {
const absolutePath = Assets.absoluteFilePath( "public.key" ); //public key file path
const publicKey = fs.readFileSync( absolutePath, "utf8" );
@chj1768
chj1768 / mms_lambda.js
Created June 12, 2017 02:17
aws s3 에 파일이 업로드될 경우 트리거되는 람다로 설정하여 외부 sms api 를 통해 업로드한 파일을 mms 메시지로 전송 연동 로직
'use strict';
const https = require('https');
const FileAPI = require('file-api');
const File = FileAPI.File;
let fs = require('fs');
let async = require('async');
let aws = require('aws-sdk');
let s3 = new aws.S3( { apiVersion: '2006-03-01' } );
@chj1768
chj1768 / jwt+googlesheets.js
Created June 12, 2017 02:15
Meteor.js에서 구글 서비스 계정 인증 + 구글시트 연동 관련 로직
import { HTTP } from 'meteor/http'
let google = require('googleapis');
const serviceId = '[email protected]';
const keyFileName = 'xxx_service_account.json';
const scopeUrl = 'https://www.googleapis.com/auth/spreadsheets';
const jwtClient = new google.auth.JWT(
serviceId, Assets.absoluteFilePath( keyFileName ), null, [ scopeUrl ]
);
jwtClient.authorize( Meteor.bindEnvironment( ( err, tokens ) => {