Skip to content

Instantly share code, notes, and snippets.

View vieron's full-sized avatar

Javier Sánchez - Marín vieron

View GitHub Profile
import { useEffect, useMemo, useState, useCallback } from "react";
import useQueryString from "./useQueryString";
function useQueryStringWithIndexValue(key, initialIndex, values) {
const computedValues = useMemo(() => values.map(v => v.toLowerCase()), [
values
]);
const [value, onSetValue] = useQueryString(key, values[initialIndex]);
const [index, setIndex] = useState(initialIndex);

Everything I Know About UI Routing

Definitions

  1. Location - The location of the application. Usually just a URL, but the location can contain multiple pieces of information that can be used by an app
    1. pathname - The "file/directory" portion of the URL, like invoices/123
    2. search - The stuff after ? in a URL like /assignments?showGrades=1.
    3. query - A parsed version of search, usually an object but not a standard browser feature.
    4. hash - The # portion of the URL. This is not available to servers in request.url so its client only. By default it means which part of the page the user should be scrolled to, but developers use it for various things.
    5. state - Object associated with a location. Think of it like a hidden URL query. It's state you want to keep with a specific location, but you don't want it to be visible in the URL.
@darencard
darencard / auto_git_file.md
Last active May 1, 2024 23:18
Automatic file git commit/push upon change

Please see the most up-to-date version of this protocol on my blog at https://darencard.net/blog/.

Automatically push an updated file whenever it is changed

Linux

  1. Make sure inotify-tools is installed (https://github.com/rvoicilas/inotify-tools)
  2. Configure git as usual
  3. Clone the git repository of interest from github and, if necessary, add file you want to monitor
  4. Allow username/password to be cached so you aren't asked everytime
@K3TH3R
K3TH3R / App.js
Last active October 1, 2017 21:56
ES6 Inheritance from ES5 Classes with EaselJS
// EaselJS still has some problems compiling with Webpack/CommonJS as of this
// publishing (01/23/2016), which makes it difficult to write modularity
// in ES6 for it. However, it's not that hard to work around:
import { Car, Mustang } from './Cars';
let createjs = window.createjs; // local reference to createjs and bypasses the current module issues
let stage = new createjs.Stage('car_canvas');
let car = new Car({
color: '#0081c9',
id: 'car1',
@addyosmani
addyosmani / README.md
Last active April 2, 2024 20:18 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@alademann
alademann / _map-get-deep-dot.scss
Last active February 25, 2019 12:40
Dot notation extension for SassyMap's map-get-deep Sass function
/**
* Fetch a deeply nested value in a multi-level map using object dot-notation string OR a list of keys.
*
* @requires sassy-maps
* @requires SassyLists
* @requires is-map
* @requires is-string
* @requires is-list
*
* @param {map} $map
@bomberstudios
bomberstudios / sketch-plugins.md
Last active February 26, 2024 07:02
A list of Sketch plugins hosted at GitHub, in no particular order.
@depoulo
depoulo / gist:5832073
Last active July 30, 2021 02:31
CSS-only multi-line ellipsis with generated content. License: http://www.wtfpl.net/txt/copying/
@import "compass/css3/images";
// CSS-only multi-line ellipsis with generated content
// yields `position:relative`, so remember to declare an eventual `position:absolute/fixed` *after* including this mixin
@mixin limitLines(
$maxLinesPortrait, // Mandatory: The number of lines after which the clipping should take action.
$maxLinesLandscape: $maxLinesPortrait, // You may provide a different line limit for landscape orientation.
// Note that 'portrait' is our default orientation. However, if you omit $maxLinesLandscape,
// the value of $maxLinesPortrait is used for whatever orientation (that is, without a media query).
@joefiorini
joefiorini / bower_importer.rb
Created May 12, 2013 15:28
A custom importer for loading bower components (regardless of CSS or SCSS) into Sass templates. Use with the bower! prefix like: @import "bower!normalize-css/normalize";
module Sass
module Importers
class BowerImporter < Sass::Importers::Filesystem
SUPPORTED_EXTNAMES = ["css", "scss", "sass"]
protected
def extensions
super.merge('css' => :scss)