Skip to content

Instantly share code, notes, and snippets.

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

Didier Cheung casdidier

🏠
Working from home
View GitHub Profile
@casdidier
casdidier / debug.css
Created October 15, 2022 08:43 — forked from paceaux/debug.css
A Sass/SCSS debug mixin
.isDebugging .debug {
outline: 1px solid rgba(200, 100, 50, 0.9);
}
.isDebugging .debug * {
outline: 1px solid rgba(200, 100, 50, 0.9);
}
@casdidier
casdidier / product.ts
Last active April 12, 2022 12:52
Flags
const isZoningMigrationEnabled =
this.appContext.project.flags?.zonings?.["zoningMigration"] &&
this.appContext.config.featureFlags["zoningV2Migration"];
@casdidier
casdidier / unpacking.js
Created December 28, 2021 11:32
smart-js-ts-snippets
import assert from "assert";
var easyUnpack = (values: any[]): any[] => [
values[0],
values[2],
values[values.length - 2],
];
console.log("Example:");
console.log(easyUnpack([1, 2, 3, 4, 5, 6, 7, 9]));
import React, { useState, useContext } from 'react';
import PropTypes from 'prop-types';
import {
Grid,
List,
ListItem,
ListItemIcon,
ListItemText,
Collapse,
Typography,
@casdidier
casdidier / dynamic-onchange.js
Created August 9, 2020 06:55 — forked from bad6e/dynamic-onchange.js
Dynamic onChange
handleChange = (event) => {
const { target: { name, value } } = event
this.setState({ [name]: value })
}
import React from 'react'
import axios from 'axios';
import { connect } from 'react-redux';
import "@fullcalendar/core/main.css";
import "@fullcalendar/daygrid/main.css";
import "@fullcalendar/timegrid/main.css";
import FullCalendar from '@fullcalendar/react'
import dayGridPlugin from '@fullcalendar/daygrid'
import timeGridPlugin from '@fullcalendar/timegrid'
@casdidier
casdidier / RoomUpdate.js
Last active May 17, 2020 09:11
State is undefined : TypeError: Cannot read property 'nombre_de_lits' of undefined
import React, { useEffect, useState } from 'react';
import { connect } from 'react-redux';
import RoomForm from '../../hooks/RoomHooks';
import RoomServiceApi from './RoomServiceApi';
const RoomUpdate = ({ update, formName, saveButton, roomId, children }) => {
const { inputs, setInputs } = useState({
nombre_de_lits: '',
logement: 'Bengalow',
lit_simple: '',
@casdidier
casdidier / RoomForm.js
Last active May 17, 2020 06:28
the fields are not updated after using useEffect
import { useState } from 'react';
const RoomForm = (initialValues, callback) => {
const [inputs, setInputs] = useState(initialValues);
const handleSubmit = (event) => {
// If we are submitting from a modal, we don't want the RoomSearch page to reload, due to the default submit behaviour.
if (event && event.target && event.target.name === 'MODAL_FORM') event.preventDefault();
// Then call back
import React from "react";
import { Modal, Button } from 'react-bootstrap';
import Room from './Room.js';
import RoomUpdate from './RoomUpdate';
const RoomModal = (props) => {
const isEdit = props.editionMode;
const roomUpdate = ({title, action}) => {
@casdidier
casdidier / emailer.py
Created April 3, 2016 09:09 — forked from sarahholderness/emailer.py
Python scripts to read a list of customer emails and send an email with the daily weather forecast
import weather
import smtp
'''
Send a greeting email to our customer email list
with the daily weather forecast and schedule
'''
def get_emails():
# Reading emails from a file