Skip to content

Instantly share code, notes, and snippets.

@edygar
edygar / Readme.md
Last active October 1, 2021 14:25
Tailwind classNames resolution

Tailwind classname resolver

A simple JavaScript utility for conditionally joining classNames together (using on classnames), but avoiding collisions on tailwind utilities. The right-most utility takes precedence over previous of the same property (eg.: border my-1 m-2 -> border m-1). This utility was inspired this tweet and it's under discussion on this thread

Usage

Here's a good example, given a component such as:

const SomeComponent = ({ className }) => 
@edygar
edygar / move.ts
Last active October 30, 2020 09:09
Move files to their kebab-version
import * as path from "https://deno.land/std@0.75.0/path/mod.ts";
import * as fs from "https://deno.land/std@0.75.0/fs/mod.ts";
import { paramCase } from "https://deno.land/x/case@v2.1.0/mod.ts";
const cwd = Deno.cwd();
// Files to be excluded during the walk
const skip = (await Deno.readTextFile(path.join(cwd, ".gitignore")))
.replace(/#.*/g, "")
.replace(/\s*\n/g, "\n")
@edygar
edygar / machine.js
Last active June 26, 2020 09:42
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@edygar
edygar / interval.ts
Last active May 27, 2020 09:46
Deno helper to call given command each given time.
/**
* # Shell interval helper
*
* Quick deno helper to call given command each given time.
*
* ## Installation:
*
* ```sh
* deno install -f --allow-run -n interval https://gist.githubusercontent.com/edygar/a1a25656d02a53c867a90fa7389ea44f/raw/interval.ts
* ```
@edygar
edygar / machine.js
Created April 28, 2020 15:49
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@edygar
edygar / README.md
Last active November 21, 2017 11:19
Eslint + Prettier

Usage

Install dependencies locally

npm install -D eslint eslint-config-airbnb eslint-config-prettier eslint-plugin-import prettier eslint-plugin-prettier eslint-plugin-jsx-a11y eslint-plugin-react flow-bin 
@edygar
edygar / .eslintrc
Last active May 30, 2016 22:57
My prefered ESlintrc
{
"extends": "eslint-config-airbnb",
"parser": "babel-eslint",
"parserOptions": {
"sourceType": "module"
},
"ecmaFeatures": {
"classes": true,
"jsx": true
},
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
init() {
setTimeout(()=>{
this.set('value',
`
<h2>Permito qualquer tag?</h2>
@edygar
edygar / application.controller.js
Last active December 23, 2015 15:01
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
init() {
setTimeout(()=>{
this.set('value',
`
<h2>Permito qualquer tag?</h2>
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
selected: 0,
options: [1, 2],
actions: {
select(index) {
this.set('selected', index);