Skip to content

Instantly share code, notes, and snippets.

@madx
madx / App.tsx
Last active July 29, 2022 05:58 — forked from j-bullard/App.tsx
Headless UI with React Hook Forms
import "./styles.css";
import { Person } from "./types";
import { Listbox } from "./listbox/listbox";
import { useForm } from "react-hook-form";
const people: Person[] = [
{ id: 1, name: "Durward Reynolds", unavailable: false },
{ id: 2, name: "Kenton Towne", unavailable: false },
{ id: 3, name: "Therese Wunsch", unavailable: false },
{ id: 4, name: "Benedict Kessler", unavailable: true },
@mxstbr
mxstbr / Readme.md
Last active December 20, 2023 12:01
Enable tab completion for JSX with Emmet in Atom

Enable tab completion for JSX with Emmet in Atom

This guide assumes you have the emmet and language-babel packages already installed in Atom

Gif of the tab completion working

  1. Open the keymap.cson file by clicking on Atom -> Keymap… in the menu bar
  2. Add these lines of code to your keymap:
'atom-text-editor[data-grammar~="jsx"]:not([mini])':
// this is the react app. it knows nothing of the vanilla app, other than that the information
// will come in in props, and that it should call this hook when this button is pressed, or etc
var Spinner = (props) =>
<div>
{this.props.data}
<button value="↑" onclick={this.props.hooks.inc}/>
<button value="↓" onclick={this.props.hooks.dec}/>
</div>;
@madx
madx / screencast-to-gif.sh
Last active September 29, 2015 06:54
Quick GIF screencasts using bash + ffcast + ffmpeg + imagemagick + yad
#!/bin/bash
FILE="$HOME/Images/Captures/`date +%FT%T.gif`"
TMP_AVI=$(mktemp /tmp/outXXXXXXXXXX.avi)
(yad --notification --image media-playback-stop --command "bash -c 'echo q; quit'") |\
ffcast -s % ffmpeg -y -f x11grab -show_region 1 -framerate 15 \
-video_size %s -i %D+%c -codec:v huffyuv \
-vf crop="iw-mod(iw\\,2):ih-mod(ih\\,2)" $TMP_AVI \
@bloodyowl
bloodyowl / .js
Created September 7, 2015 09:23
ES6 vs ES5
const f = ({ foo = "foo", bar = "bar" } = {}, ...args) => ({
foo,
[`${ bar }1`]: args,
})
// vs
var f = function(options) {
var args = [].slice.call(arguments, 1)
options = options !== undefined ? options : {}
<?php
/**
* Plugin Name: Gulp Sitemap Generator
* Plugin URI: https://gladdy.uk/blog/2014/04/13/using-uncss-and-grunt-uncss-with-wordpress/
* Description: Generate a JSON list of every page on a site so it can be used with Gulp and uncss.
* Author: Liam Gladdy
* Author URI: http://gladdy.co.uk
* Version: 1.0
*/
@MoOx
MoOx / cleanup-svg.js
Last active April 18, 2020 19:12
Cleanup svg
cleanupSvg(svg) {
return [
// some useless stuff for us
// that svgo doesn't remove
/<title>.*<\/title>/gi,
// remove hardcoded dimensions
/ +width="\d+(\.\d+)?(px)?"/gi,
/ +height="\d+(\.\d+)?(px)?"/gi,

When a beginner asks you "when do I use semi-colons?" would you rather say this?

// what people who say "use semicolons!!" say
class Foo {
  prop = {
  }; // yes
@bloodyowl
bloodyowl / gist:5d8adcf50e890ebafb95
Last active September 30, 2023 16:49
ES6 tl;dr; for beginners
// ES6 tl;dr; for beginners
// 1. variables
// `const` & `let` are scoped at the block level
if(true) {
let foo = "bar"
}
foo // ReferenceError
@tdd
tdd / angular-just-say-no.md
Last active November 18, 2022 20:47
Angular: Just Say No

Angular: Just say no

A collection of articles by AngularJS veterans, sometimes even core committers, that explain in detail what's wrong with Angular 1.x, how Angular 2 isn't the future, and why you should avoid the entire thing at all costs unless you want to spend the next few years in hell.

Reason for this: I'm getting tired of having to explain to everyone, chief of which all the indiscriminate Google Kool-Aid™ drinkers, why I have never believed in Angular, why I think it'll publicly fail pretty soon now (a couple years), and why it's a dead end IMO. This gist serves as a quick target I can point people to in order not to have to parrot / compile the core of the articles below everytime. Their compounded reading pretty much captures 99% of my view on the topic.

This page is accessible through http://bit.ly/angular-just-say-no and http://bit.ly/angularjustsayno, btw.