Skip to content

Instantly share code, notes, and snippets.

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

Antonio Caputo tonycaputome

🏠
Working from home
  • Frontend Engineer
  • Milan, Italy
View GitHub Profile
@nikasepiskveradze
nikasepiskveradze / react-query-lite.js
Last active July 15, 2024 12:26
Lightweight implementation of React Query
import React from "react";
const context = React.createContext();
export function QueryClientProvider({ children, client }) {
React.useEffect(() => {
const onFocus = () => {
client.queries.forEach((query) => {
query.subscribers.forEach((subscriber) => {
subscriber.fetch();
@whisher
whisher / gist:c8e0453a5fa76b5d6d952919c77ef0c4
Last active January 28, 2023 06:07
reactjs typescript useForm - a simple custom hook to manage form in react
Credit to
https://medium.com/javascript-in-plain-english/react-controlled-forms-with-hooks-538762aab935
import React, { ChangeEvent, FormEvent, useReducer } from "react";
const useForm = (initialState: any) => {
const reducer = (
state: typeof initialState,
payload: { field: string; value: string }
) => {
@kjbrum
kjbrum / Base.js
Last active April 19, 2023 22:51
React primitive components using styled-system (with styled-components).
import React, { forwardRef } from 'react'
import styled from 'styled-components'
import css, { get } from '@styled-system/css'
import {
system,
compose,
space,
color,
typography,
layout,
@MaximeHeckel
MaximeHeckel / Example.js
Last active April 6, 2022 22:11
Example of App replacing Redux with Context and Hooks
// reducer.js
export const initialState = {
data: null
};
const reducer = (state, action) => {
const reduced = { ...state };
switch (action.type) {
case "FETCH_DATA":
return {
@Metnew
Metnew / route protected by authentication react-router 4
Created April 15, 2017 15:58
route protected by authentication react-router 4
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import {Route, Redirect} from 'react-router'
/**
* Component that protects route from unauthorized users.
* @type {Object}
*/
class RouteAuth extends Component {
constructor(props) {
@btroncone
btroncone / rxjs_operators_by_example.md
Last active June 15, 2024 07:17
RxJS 5 Operators By Example
@csaftoiu
csaftoiu / foundation-datepicker-angular.js
Created November 9, 2015 21:50
Angular binding for Foundation Datepicker
'use strict';
/**
* @ngdoc overview
* @name foundation.datepicker.angular
* @description
* # foundation.datepicker.angular
*
* Add angular support for {@link http://foundation-datepicker.peterbeno.com/example.html foundation-datepicker}.
*/
@joshrathke
joshrathke / instagram_advanced_query.php
Last active August 29, 2015 14:21
This gist shows a workaround for getting media from a specific author, tagged with a specific hashtag. This does have the potential to cause a very long request time, and is best to be used in conjunction with uncommon and very specific hashtags for "seemingly" normal response times.
<?php
/**
* By default instagram doesn't allow us to query for more than
* attribute, such as media posted by a specific author tagged with
* a specific tag. In order to accomplish this we will acquire all of
* the media tagged with the tag we are looking for and then filter it
* down based on the user.
*/
@ericelliott
ericelliott / essential-javascript-links.md
Last active July 18, 2024 15:03
Essential JavaScript Links
@demisx
demisx / _angularjs-1-component-organization.md
Last active July 14, 2023 14:07
AngularAtom--Component-based organization for AngularJS 1.x apps. Read more on AngularAtom organization at http://demisx.github.io/angularjs/atom/component-feature-based-organization/2014/12/02/angular-1-component-organization-1.html

Angular application directory structure

Leverages Angular UI Router instead of core ngRoute module. UI Router allows us to organize our application interface into a state machine. Unlike the $route service in the Angular ngRoute module, which is organized around URL routes, UI-Router is organized around states, which may optionally have routes, as well as other behavior, attached.

LIFT* Organization principle:

  • L - Locating code easy
  • I - Identify code at a glance