Skip to content

Instantly share code, notes, and snippets.

View AndreiF13's full-sized avatar

Andrei F. AndreiF13

View GitHub Profile
@AndreiF13
AndreiF13 / cloudSettings
Last active April 26, 2020 06:26
vscode-sync-settings
{"lastUpload":"2020-04-26T06:26:34.097Z","extensionVersion":"v3.4.3"}
@AndreiF13
AndreiF13 / finalFormHooks.ts
Created October 16, 2019 09:43 — forked from alitaheri/finalFormHooks.ts
Type safe react-final-form-hooks
import { useCallback, useRef, useState, useEffect, useMemo } from 'react';
import {
FormApi,
FormState,
FieldState,
Config,
FormSubscription,
FieldSubscription,
FieldValidator,
formSubscriptionItems,
const useFetch = endpoint => {
const defaultHeader = {
Accept: "application/json",
"Content-Type": "application/json"
};
const customFetch = (
url,
method = "GET",
body = false,
headers = defaultHeader

Pluck Unique Values from Array of Javascript Objects

Implementation

const pluck = key => array => Array.from(new Set(array.map(obj => obj[key])));

Usage

@AndreiF13
AndreiF13 / group-objects-by-property.md
Created December 11, 2019 18:25 — forked from JamieMason/group-objects-by-property.md
Group Array of JavaScript Objects by Key or Property Value

Group Array of JavaScript Objects by Key or Property Value

Implementation

const groupBy = key => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = obj[key];
    objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
    return objectsByKeyValue;
@AndreiF13
AndreiF13 / __responsive styled components
Created December 17, 2019 21:08 — forked from granmoe/__responsive styled components
Programmatically create responsive styled components with react and styled-components
// this file is just here to change the name of the gist
import React from 'react'
import styled from 'styled-components'
const makeResponsiveComponent = (rulesets, tagName = 'div') =>
styled(tagName)`${buildStyles(rulesets)}`
const buildStyles = rulesets =>
rulesets.reduce(
(cssString, { constraint, width, rules }) =>
@AndreiF13
AndreiF13 / findUser.js
Last active January 2, 2020 15:24 — forked from paigen11/findUser.js
Passport local and Passport JWT authentication with custom callbacks examples with a user registration MERN service.
import passport from 'passport';
module.exports = app => {
app.get('/findUser', (req, res, next) => {
passport.authenticate('jwt', { session: false }, (err, user, info) => {
if (err) {
console.log(err);
}
if (info != undefined) {
console.log(info.message);
keywords.select2({
tags: true,
createTag: function (params) {
var term = $.trim(params.term);
var count = 0
var existsVar = false;
//check if there is any option already
if($('#keywords option').length > 0){
$('#keywords option').each(function(){
if ($(this).text().toUpperCase() == term.toUpperCase()) {
@AndreiF13
AndreiF13 / SSLXampp.md
Created June 8, 2020 06:08 — forked from nguyenanhtu/SSLXampp.md
Guide to configure SSL in XAMPP for Windows

How to test 'https' in XAMPP for localhost ? I will guide you

Menu

  • Create certificate
  • Config Apache to access https instead of http
  • Config mod rewrite to generate SSL url
  • Config Virtual host to test site

Step 1 : Create certificate

  • Go to your XAMPP installation directory (in my case it’s E:\xampp), figure out apache folder. In this, find & run batch file
@AndreiF13
AndreiF13 / wp-debug
Created June 28, 2020 08:23
WordPress debug
To log errors triggered by WordPress plugins, you can use the debug log.
Edit your wp-config.php file
Add the following lines to enable debug (if these are already defined, edit the values):
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );