Skip to content

Instantly share code, notes, and snippets.

View ManotLuijiu's full-sized avatar
🏠
Working from home

Manot Luijiu ManotLuijiu

🏠
Working from home
View GitHub Profile
@ManotLuijiu
ManotLuijiu / landing.html
Created January 23, 2021 16:50
Django templates/landing.html
{% extends "base.html" %} {% block content %}
<section class="text-gray-600 body-font">
<div
class="container mx-auto flex px-5 py-24 items-center justify-center flex-col"
>
<img
class="lg:w-2/6 md:w-3/6 w-5/6 mb-10 object-cover object-center rounded"
alt="hero"
src="https://dummyimage.com/720x600"
/>
@ManotLuijiu
ManotLuijiu / leads folder
Last active January 24, 2021 15:56
Django app leads folder
leads
.
├── __pycache__
│ ├── __init__.cpython-39.pyc
│ ├── admin.cpython-39.pyc
│ ├── forms.cpython-39.pyc
│ ├── models.cpython-39.pyc
│ ├── urls.cpython-39.pyc
│ └── views.cpython-39.pyc
├── migrations
@ManotLuijiu
ManotLuijiu / Layout.js
Created January 31, 2021 12:27
In case, you need to hide some component in react.js or next.js
import React from 'react';
import { useRouter } from 'next/router';
import Nav from './Nav';
import Header from './Header';
import Footer from './Footer';
const Layout = ({ children }) => {
const router = useRouter();
@ManotLuijiu
ManotLuijiu / toggle-show-hide-element.js
Last active February 23, 2021 07:33
How to hide element in JavaScript
document.onscroll = function() {
if (window.innerHeight + window.scrollY > document.body.clientHeight) {
document.getElementById('means__social__th').style.display='none';
}
if (document.getElementById('means__social__th') && \
window.innerHeight + window.scrollY < document.body.clientHeight) \
{
document.getElementById('means__social__th').style.display='block';
}
}
@ManotLuijiu
ManotLuijiu / wp-script.js
Last active February 20, 2021 14:50
WordPress Script for take care social icons toggle hide/show using Elementor & Essential Addons
document.onscroll = function () {
var e = window,
a = 'inner';
var viewportWidth;
var viewportHeight;
if (!('innerWidth' in window)) {
a = 'client';
e = document.documentElement || document.body;
}
viewportWidth = { width: e[a + 'Width'] };
@ManotLuijiu
ManotLuijiu / my-opacity.js
Created February 21, 2021 04:28
Get elements then inject opacity from 0 to 1
document.addEventListener('DOMContentLoaded', () => {
var myOpacity = 0;
var readMeter = document.getElementsByClassName('bsf-rt-display-label')[0];
var readUnit = document.getElementsByClassName('bsf-rt-display-postfix')[0];
var readColor = document.getElementsByClassName('bsf-rt-reading-time')[0];
function MyFadeFunction() {
if (myOpacity < 1) {
myOpacity += 0.075;
setTimeout(function () {
@ManotLuijiu
ManotLuijiu / jest.config.js
Created March 2, 2021 14:01
Jest config for NextJS, need to install "identity-obj-proxy"
module.exports = {
testPathIgnorePatterns: ['<rootDir>/.next/', '<rootDir>/node_modules/'],
setupFilesAfterEnv: ['<rootDir>/setupTests.js'],
transform: {
'^.+\\.(js|jsx|ts|tsx)$': '<rootDir>/node_modules/babel-jest',
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/fileTransformer.js',
},
};
@ManotLuijiu
ManotLuijiu / setupTests.js
Created March 2, 2021 14:03
Put setupTests.js in the root folder of NextJS
import '@testing-library/jest-dom/extend-expect';
@ManotLuijiu
ManotLuijiu / fileTransformer.js
Created March 2, 2021 14:05
Change file logo.jpg to logo
const path = require('path');
module.exports = {
process(src, filename, config, options) {
return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';';
},
};
@ManotLuijiu
ManotLuijiu / index.js
Created March 18, 2021 14:31
Upload Excel to MongoDB
const fs = require('fs');
const multer = require('multer');
const express = require('express');
let MongoClient = require('mongodb').MongoClient;
let url = 'mongodb://localhost:27017/';
const excelToJson = require('convert-excel-to-json');
const app = express();