This file contains 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 { Steps, FromFile, LosslessPNG, FromURL } = require("@imazen/imageflow") | |
new Steps(new FromFile(process.argv[2])) | |
.watermark(new FromURL("https://res.cloudinary.com/unbaked/image/upload/v1591363414/frame_e2n8fi.png"), {}) | |
.encode(new FromFile("./with_frame.png"), new LosslessPNG()).execute() |
This file contains 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
use nodejs_sys::{napi_env, napi_value, napi_create_string_utf8, napi_set_named_property}; | |
use std::ffi::CString; | |
#[no_mangle] | |
pub unsafe extern "C" fn napi_register_module_v1( | |
env: napi_env, | |
m: napi_value, | |
) -> nodejs_sys::napi_value { | |
let key = CString::new("hello").expect("CString::new failed"); | |
let mut local: napi_value = std::mem::zeroed(); |
This file contains 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
use nodejs_sys::{ | |
napi_async_work, napi_callback_info, napi_create_async_work, napi_create_promise, | |
napi_deferred, napi_delete_async_work, napi_env, napi_get_cb_info, napi_queue_async_work, | |
napi_resolve_deferred, napi_status, napi_value,napi_reject_deferred,napi_create_error | |
}; | |
use std::ffi::c_void; | |
use crate::{request, scrap, types}; | |
#[derive(Debug, Clone)] |
This file contains 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
npm i -g create-react-app | |
create-react-app session | |
cd ./session | |
npm start |
This file contains 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
<input type="text" id="input"> | |
<script> | |
const el= document.querySelector('#input') | |
el.addEventListener('change',(e)=>{ | |
console.log(e.target.value); | |
}) | |
</script> |
This file contains 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
/** | |
* authenticator - check for token and add user to req | |
* | |
* @param {Object} req the req object contains all the info about request | |
* @param {Object} res the res object contains many methods to respond to request | |
* @param {Object} next to pass ther control to next middleware | |
* | |
* @returns {undefined} | |
*/ | |
async function authenticator(req, res, next) { |
This file contains 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 jwt = require("jsonwebtoken"); | |
const config = require("../../config")(); | |
module.exports = { | |
/** | |
* sign - create a jwt from payload. | |
* | |
* @param {Object} payload the payload send to the user | |
* @param {Function} callback function envoked with two parameters | |
* 1. error the error in operation |
This file contains 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
async function loginUser(userObject, callback) { | |
// some validation for the request body or data supplied to function | |
const { error, value } = Joi.validate(userObject, userObjectSchema); | |
if (error) { | |
callback(error); | |
} else { | |
try { | |
// check for validate of the access torken the code for it is given in pervious example | |
const isTokenValid = await fbHelper.validateToken( | |
userObject.access_token, |
This file contains 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
/** | |
* validateToken - validate the token supplied by the frontend | |
* @param {String} token the token supplied by the front end | |
* @param {String} ffid the ffid of the user | |
*/ | |
async function validateToken(token, ffid) { | |
const data = await request.get( | |
`https://graph.facebook.com/debug_token?input_token=${token}&access_token=${ | |
config.FB.APP_ID | |
}|${config.FB.APP_SECERET}` |
This file contains 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, { useState, Fragment, useEffect } from "react"; | |
import { Formik, Field } from "formik"; | |
import s from "./app.component.css"; | |
import * as yup from "yup"; | |
const intialState = { | |
name: "", | |
email: "", | |
password: "" | |
}; |
NewerOlder