Skip to content

Instantly share code, notes, and snippets.

const ids = [];
const data = ['139', '576'];
data.map(id => ids.push(Math.max(...id)));
// What's the output?
console.log(ids);
@juliovedovatto
juliovedovatto / remove_duplicates_array_multi.js
Created December 3, 2016 19:42
Javascript: Remove duplicates of multidimensional array
// for browser using, this code requires javascript 1.7+
var arr = [
{ foo: 'bar', lorem: 'ipsum' },
{ foo: 'bar', lorem: 'ipsum' },
{ foo: 'bar', lorem: 'ipsum dolor sit amet' }
];
arr = arr.map(JSON.stringify).reverse() // convert to JSON string the array content, then reverse it (to check from end to begining)
.filter(function(item, index, arr){ return arr.indexOf(item, index + 1) === -1; }) // check if there is any occurence of the item in whole array
@elitan
elitan / ContactForm.js
Last active November 9, 2022 05:21
React Router V4 Redirect after form submission
import React, { Component } from 'react';
import { withRouter } from 'react-router-dom'; // <--- import `withRouter`. We will use this in the bottom of our file.
class ContactForm extends Component {
submitForm (e) {
e.preventDefault()
this.props.history.push('/thank-you'); // <--- The page you want to redirect your user to.
}
@foosel
foosel / README.md
Last active January 12, 2023 16:25
Getting the fingerprint reader of a Thinkpad x240 to work under Ubuntu 14.04

lsusb lists the fingerprint reader in the x240 as follows:

Bus 002 Device 003: ID 138a:0017 Validity Sensors, Inc.

There exists experimental driver support for this in a fork of libfprint for vfs5011 sensors, however you'll need to compile the driver yourself. To get the fingerprint sensor to work for lightdm login, su etc, follow these steps.

  1. Install fingerprint-gui:

    sudo add-apt-repository ppa:fingerprint/fingerprint-gui
    
HTML
- Semantic HTML
- Event delegation
- Accessibility / ARIA
CSS
- Specificity
- Pseudo-elements
- Pseudo-selectors
- Combinators
@crmaxx
crmaxx / backup_brew.rb
Created November 30, 2013 01:40
backup installed brew packages
brew list > brew_list_tmp.txt
for each brew_list_tmp.txt do |pkg|
brew info pkg
get install string from "Built from source with:"
add "brew install #{pkg} #{params}" to brew_list.txt
end
@rauschma
rauschma / impatient-js-es2021.md
Last active August 31, 2023 07:02
ES2021 edition of “JavaScript for impatient programmers”

What is new in the ES2021 edition of “JavaScript for impatient programmers”?

Free to read online: exploringjs.com/impatient-js/

  • The exercises now run as native ESM modules on Node.js. Previously, they were run via the esm package.
  • Material on new ES2021 features:
    • String.prototype.replaceAll()
    • Promise.any()
    • Logical assignment operators
  • Underscores (_) as separators in number literals and bigint literals
@stevekinney
stevekinney / front-end-curriculum.md
Created August 9, 2015 00:47
Front-end Curriculum Draft

Module 1

  • Semantic markup
  • HTML standards mode and quirks mode
  • HTML fundamentals
    • Classes and IDs
  • CSS fundamentals
    • Selectors
    • Resets and normalizers
    • The box model
@zcaceres
zcaceres / basic-js-greatest-hits.md
Last active March 23, 2024 22:44
Articles Written to Help New JS Devs
@zenorocha
zenorocha / etc-hosts-on-win.md
Last active April 11, 2024 23:07
/etc/hosts on Windows

1. Get your IP Address

echo `ifconfig $(netstat -nr | grep -e default -e "^0\.0\.0\.0" | head -1 | awk '{print $NF}') | grep -e "inet " | sed -e 's/.*inet //' -e 's/ .*//' -e 's/.*\://'`

2. Modify your hosts file

notepad