This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PetsPlugin { | |
public boot() { | |
User::extend(function($model) { | |
// Evitiamo di salvare i 'pet_save_data' nel DB | |
$model->purgeable[] = ['pet_save_data']; | |
// Quando viene salvato un User, provvediamo a salvare anche il Pet correlato | |
$model->bindEvent('beforeSave', function($user) { | |
$pet = Pet::where('user_id', $user->id)->findOne(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Just a snippet, but it should work | |
*/ | |
const { | |
roundedHeight, | |
height, | |
width | |
} = this.props; | |
const heightSq = Math.pow(roundedHeight - height, 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Jekyll v1 made internal markdown converters. | |
# Here we change the module, allowing our custom parser to be used. | |
module Jekyll | |
module Converters | |
class Markdown < Converter | |
safe true | |
pygments_prefix "\n" | |
pygments_suffix "\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Let's define our context... | |
const ThemeContext = React.createContext(...); | |
// This component is nested in a `ThemeContext.Provider` node.. | |
function MyComponent(props: Props) { | |
// No more HOCs! | |
const theme = useContext(ThemeContext); | |
// It's a kind of magic | |
return ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HOC. Conterrà sia le proprietà del connect che quelle del componente in se | |
interface Props {} | |
function Component(props: Props) { | |
return ...; | |
} | |
export const ComponentConnected = connect(...)(Component); | |
// Hook. I dati del `connect` sono interni al Componente |
OlderNewer