Skip to content

Instantly share code, notes, and snippets.

@thomasheyenbrock
thomasheyenbrock / typesafe-graphql-queries.ts
Last active April 19, 2022 08:30
Building type-safe queries with variables- and result-types in GraphQL
/* eslint-disable */
/**
* What do we want to achieve here? 👀
*
* 1. Write type-safe GraphQL queries with autocomplete and all the cool stuff
* 2. For the query we just wrote, we want to have...
* a. ...types for the resulting data
* b. ...types for the used variables
*
@Jaid
Jaid / migratingRules.md
Last active September 30, 2024 16:14
ESLint rules for migrating projects from CommonJS to ESM

ESLint rules

The ESM standard is considered stable in NodeJS and well supported by a lot of modern JavaScript tools.

ESLint does a good job validating and fixing ESM code (as long as you don't use top-level await, coming in ESLint v8). Make sure to enable the latest ECMA features in the ESLint config.

  • .eslint.json
{
@Purpzie
Purpzie / update-lockfile.yml
Last active May 6, 2023 13:22
Action to update pnpm-lock.yaml when Dependabot opens a PR. Be warned that this may cause lots of merge conflicts.
# https://github.com/dependabot/dependabot-core/issues/1736
name: Dependabot
on: pull_request_target
permissions: read-all
jobs:
update-lockfile:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
permissions:
pull-requests: write
@sindresorhus
sindresorhus / esm-package.md
Last active November 17, 2024 22:07
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@hikari-no-yume
hikari-no-yume / example.php
Created March 20, 2017 20:02
function chaining for PHP 7
<?php declare(strict_types=1);
require_once "✨.🐘";
✨($_)->strlen("foo")->var_dump($_);
@dg
dg / websocket.html
Created August 11, 2013 15:54
WebSocket communication between PHP and single client
<!doctype html>
<script>
if ("WebSocket" in window) {
var ws = new WebSocket("ws://127.0.0.1:31339");
ws.onopen = function() {
console.log('connected');
};
ws.onerror = function(e) {
<?php
namespace Model;
class Post extends BaseModel
{
/** @var int */
private $id;
@janmarek
janmarek / LessFilter.php
Created November 11, 2010 21:45
LessFilter pro WebLoader
<?php
namespace Webloader;
use Nette\String, lessc;
/**
* Less CSS filter
*
* @author Jan Marek
@janmarek
janmarek / FormMacros.php
Created March 28, 2010 21:30
Form macros
<?php
namespace Nette\Templates;
use Nette\Forms\Form;
use Nette\String;
/**
* Form macros
*