Skip to content

Instantly share code, notes, and snippets.

Avatar

Kouji Nakashima kuc-arc-f

View GitHub Profile
@kuc-arc-f
kuc-arc-f / uart_echo_example_main.c
Created May 24, 2017
esp32, UART sample (UART2)
View uart_echo_example_main.c
/* Uart Events Example
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include <string.h>
@kuc-arc-f
kuc-arc-f / rollup.config.js
Created Jun 30, 2021
svelte-apollo, setting sample
View rollup.config.js
import svelte from 'rollup-plugin-svelte';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
import css from 'rollup-plugin-css-only';
import replace from '@rollup/plugin-replace';
const production = !process.env.ROLLUP_WATCH;
@kuc-arc-f
kuc-arc-f / index.js
Created Jun 14, 2021
Apollo server + express , GraphQL sample
View index.js
// Apollo server + express , GraphQL sample
const express = require('express');
const { ApolloServer, gql } = require('apollo-server-express');
const typeDefs = gql`
type Todo {
id: Int!
title: String
}
type Query {
@kuc-arc-f
kuc-arc-f / index.json.js
Last active Jun 12, 2021
sveltekit sample, cms display
View index.json.js
import Config from '../../../app_config'
// GET /xxx.json
export const get = async (request) => {
var cfg = Config.get_config()
const res = await fetch( cfg.MY_JSON_URL);
const posts = await res.json();
if (res.status === 404) {
return { body: [] };
}
@kuc-arc-f
kuc-arc-f / LibFlash.js
Created Jun 2, 2021
Sapper Flash function
View LibFlash.js
var csrf = require('csrf');
var tokens = new csrf();
//
export default {
set_falsh:async function(req, flash_message){
try{
//console.log(flash_message)
var arr = {message:'', error:''}
View test.svelte
<script context="module">
import axios from 'axios'
export async function preload() {
var url ="/api/get_token";
const res = await this.fetch(url)
const data = await res.json()
//console.log(data)
var csfr = data
return {csfr};
}
@kuc-arc-f
kuc-arc-f / bcrypt.js
Created Jun 1, 2021
sapper , bcrypt sample
View bcrypt.js
// sapper , bcrypt sample
const bcrypt = require('bcrypt');
//
export async function get(req, res) {
try{
const input_pass= "pas123"
let hashed_password = bcrypt.hashSync(input_pass , 10);
console.log( hashed_password )
if(bcrypt.compareSync(input_pass, hashed_password )){
@kuc-arc-f
kuc-arc-f / server.js
Created May 31, 2021
sapper session use
View server.js
import sirv from 'sirv';
import polka from 'polka';
import compression from 'compression';
import * as sapper from '@sapper/server';
const { json } = require('body-parser');
var cookieParser = require('cookie-parser');
import session from 'express-session';
const { PORT, NODE_ENV } = process.env;
const dev = NODE_ENV === 'development';
@kuc-arc-f
kuc-arc-f / query.js
Created May 31, 2021
sapper, get query sample
View query.js
// sapper, get query sample
// URL : http://localhost:3000/api/query?hoge=1&fuga=2
//
export async function get(req, res) {
try{
console.log( req.query )
console.log( "hoge=", req.query.hoge )
console.log( "fuga=", req.query.fuga )
res.writeHead(200, {
@kuc-arc-f
kuc-arc-f / server.js
Created May 30, 2021
sapper POST setting
View server.js
import sirv from 'sirv';
import polka from 'polka';
import compression from 'compression';
import * as sapper from '@sapper/server';
const { json } = require('body-parser');
const { PORT, NODE_ENV } = process.env;
const dev = NODE_ENV === 'development';
polka() // You can also use Express