Skip to content

Instantly share code, notes, and snippets.

View Cerwyn's full-sized avatar
🤩
Amazing

Cerwyn Eliata Cerwyn

🤩
Amazing
View GitHub Profile
@Cerwyn
Cerwyn / StoreContext.ts
Last active June 26, 2021 11:16
preact
import { html } from 'htm/preact';
import { createContext } from 'preact';
import { useLocalStore } from 'mobx-react-lite';
export const StoreContext = createContext(undefined);
export const StoreProvider = ({ children }) => {
const store = useLocalStore(() => ({
counter: 0,
setCounter: (number) => {
@Cerwyn
Cerwyn / app.ts
Created June 26, 2021 10:57
preact
import { html } from 'htm/preact';
import { Router } from 'preact-router';
import Header from './header';
// Code-splitting is automated for `routes` directory
import Home from '../routes/home';
import Profile from '../routes/profile';
const App = () => {
@Cerwyn
Cerwyn / index.ts
Last active June 27, 2021 00:23
preact
import { FunctionalComponent } from 'preact';
import { html } from 'htm/preact';
import { useEffect, useState } from "preact/hooks";
import style from './style.scss';
// Note: `user` comes from the URL, courtesy of our router
const Profile: FunctionalComponent = (props: any) => {
const { user } = props;
@Cerwyn
Cerwyn / index.ts
Last active June 26, 2021 10:22
preact
import { html } from 'htm/preact';
import style from './style.css';
import { FunctionalComponent } from 'preact';
const Home: FunctionalComponent = () => {
return html`
<div class="${style.home}">
<h1>Home</h1>
<p>This is the Home component.</p>
</div>
@Cerwyn
Cerwyn / lint-staged.config.js
Created June 5, 2021 12:05
lint-staged.config.js
module.exports = {
'resources/**/*.{css,js}': ['prettier --write'],
'**/*.php': ['php ./vendor/bin/php-cs-fixer fix --config .php-cs-fixer.php --allow-risky=yes'],
};
@Cerwyn
Cerwyn / .php-cs-fixer.php
Created June 5, 2021 12:04
.php-cs-fixer.php
<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude(['bootstrap', 'storage', 'vendor'])
->name('*.php')
->name('_ide_helper')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);
<?php
public function store(Request $request)
{
DB::beginTransaction();
$user = User::create();
$response = app('service')->create($user);
if (!$response) {
<!DOCTYPE html>
<html>
<head>
<title>DRY</title>
</head>
<body>
<h1>Custom Calendar</h1>
<x-custom-calendar>
<?php
Article::has('user.profile')->verified()->latest()->get();
<?php
SELECT *
FROM `articles`
WHERE EXISTS (SELECT *
FROM `users`
WHERE `articles`.`user_id` = `users`.`id`
AND EXISTS (SELECT *
FROM `profiles`
WHERE `profiles`.`user_id` = `users`.`id`)
AND `users`.`deleted_at` IS NULL)