Skip to content

Instantly share code, notes, and snippets.

View Rowadz's full-sized avatar
🤙
🦖🦖

Mohammad Alrawad Rowadz

🤙
🦖🦖
View GitHub Profile
module.exports = function (app) {
return async (req, res, next) => {
const {
files
} = req;
const fileRes = [];
const seq = app.get('sequelizeClient');
const { media } = seq.models;
for (const file of files) {
// eslint-disable-next-line no-unused-vars
module.exports = function(options = {}) {
// Return the actual hook.
return async context => {
// relationRecords are array of data
// e.g: Array<Comments> || Array<Likes> which sequelize will not handle in a patch request
const { id, data: { relationRecords } } = context;
const service1 = context.app.service('relation1Service');
await removeOldData(service1, +id);
await addNewData(service1, +id, relationRecords);
@Rowadz
Rowadz / NaomitsuService.service.ts
Last active December 6, 2020 19:28
generic angular http service
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { isNull } from 'util';
interface QueryParams {
[key: string]: string | number;
}
export interface Post {
@Rowadz
Rowadz / monitoring_binary_logs.js
Created September 26, 2019 01:08
Monitoring binary logs via Nodejs
const mysql = require('mysql');
const MySQLEvents = require('@rodrigogs/mysql-events');
const ora = require('ora'); // cool spinner
const spinner = ora({
text: '🛸 Waiting for database events... 🛸',
color: 'blue',
spinner: 'dots2'
});
const program = async () => {
const getById = (id) => {
console.log('get')
return document.getElementById(id)
}
// IIFE
setInterval(
(() => {
const h1 = getById('display-number')
const { floor, random } = Math
return () => {
const { series, parallel, src, dest } = require('gulp')
const { sync } = require('glob')
const sass = require('gulp-sass')
const { join } = require('path')
const cleanCSS = require('gulp-clean-css')
const babel = require('gulp-babel')
const uglify = require('gulp-uglify')
sass.compiler = require('node-sass')
const path = join(__dirname, 'src')
@Rowadz
Rowadz / compose_functions.py
Created October 9, 2020 17:10
A function in python that compose functions together
from functools import reduce
def func01(name): return f'{name}-func01'
def func02(name): return f'{name}-func02'
def func03(name): return f'{name}-func03'
def func04(name): return f'{name}-func04'
def func05(name): return f'{name}-func05'
const func01 = (name) => `${name}-func01`
const func02 = (name) => `${name}-func02`
const func03 = (name) => `${name}-func03`
const func04 = (name) => `${name}-func04`
const func05 = (name) => `${name}-func05`
const result = func01(func02(func03(func04(func05('rowadz')))))
console.log(result)
@Rowadz
Rowadz / combineEntityAdapterStates.js
Last active March 18, 2022 00:14
combining multiple createEntityAdapter generated state into the same slice from redux toolkit
import {
createSlice,
createEntityAdapter,
createAsyncThunk,
} from '@reduxjs/toolkit'
export const fetchData = createAsyncThunk(
'users/fetchData',
async (_, { dispatch }) => {
const data = await fetch('http://localhost:3001/users').then((res) =>
import React, { useState } from 'react'
import ReactDOM from 'react-dom'
import { Button } from 'rsuite'
import 'rsuite/dist/styles/rsuite-dark.css'
import { generate } from 'shortid'
import User from './User'
import Viewer from './Viewer'
const App = () => {
const [users, setUsers] = useState([