Skip to content

Instantly share code, notes, and snippets.

View apotox's full-sized avatar
📚
reading

Safi eddine apotox

📚
reading
  • Software Engineer
  • berlin
  • 00:24 (UTC +02:00)
View GitHub Profile
@apotox
apotox / namer.js
Created May 27, 2020 20:06
javascript random string generator with options
export const namer = ({
length = 5,
useDigit = true,
useAlpha = true,
upperOnly = false,
lowerOnly = false,
}) => {
let str = [];
let stock = [];
@apotox
apotox / firebaseApiGwAuthorizer.js
Last active June 6, 2021 08:09
AWS custom api gateway authorizer using firebase auth JWT
const admin = require('firebase-admin');
//from your firebase project service
const serviceAccount = {
"type": "",
"project_id": "",
"private_key_id": "",
"private_key": "",
"client_email": "",
"client_id": "",
@apotox
apotox / secretData.js
Created March 20, 2020 13:09
netlify lambda function protected by firebase auth
const { success, failed } = require("./services/responses");
const { VerifyToken } = require("./services/security");
exports.handler = async (event, context) => {
context.callbackWaitsForEmptyEventLoop = false;
const user = await VerifyToken(event.queryStringParameters.token);
if (!user) return failed("unauthorized", 401);
@apotox
apotox / gatsby-node.js
Last active March 18, 2020 19:38
a gatsby-source plugin example
const fetch = require("node-fetch");
const { api_url } = require("./config");
exports.sourceNodes = async (
{ reporter, actions, createNodeId, createContentDigest },
options
) => {
if (process.env.NODE_ENV == "development") {
reporter.warn("Welcome to MYCustomer Plugin");
}
@apotox
apotox / itemTodo.actions.js
Last active March 20, 2020 23:57
async redux action to delete items from remote
export const DELETE_ITEMS = payload => {
return (dispatch, getState, api) => {
api.delete(`items?ids=${payload}`)
.then(() => {
//dispatch(SUCCESS_NOTIFICATION())
})
.catch(err => {
@apotox
apotox / store.js
Created March 16, 2020 19:45
redux store with thunk middleware and extra Axios parameter
import axios from 'axios'
import {combineReducers, createStore, applyMiddleware} from 'redux'
import thunk from 'redux-thunk'
import listTodoReducer from './components/ListTodo/ListTodo.reducer'
const API_ENDPOINT = "https://api...."
//combine project reducers
const reducers = combineReducers({
listTodoReducer
@apotox
apotox / RSASIGNATURE.cs
Created January 23, 2020 14:01
RSA signature sample code without RSACryptoServiceProvider
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Globalization;
@apotox
apotox / restarting.sh
Created January 20, 2020 14:19
restart a Linux process in a background Screen.
#restart a process in a background Screen.
ps aux | awk '/process_filename/ {print}' | awk '{print $2}' | xargs kill -SIGTERM
echo "restarting process_filename.."
screen -r <screen_id> -X stuff $"/path/to/process_filename -params=123\n"
@apotox
apotox / dark-light-switch-button.css
Last active January 15, 2020 11:08
custom style for checkbox to switch between Dark/Light theme (https://jsfiddle.net/saphidev/uom9wL0f/)
.switch{
position: relative;
display: block;
width: 26px;
padding: 1px;
height: 14px;
border: 1px solid #ccc;
border-radius: 6px;
}
@apotox
apotox / .travis.yml
Created December 25, 2019 13:36
travis deploy to firebase hosting
language: node_js
node_js:
- node
cache:
directories:
- node_modules
script:
- yarn install
- yarn test
- yarn build