A Pen by Abhijeet De on CodePen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :set list to enable. | |
| :set nolist to disable. | |
| As others have said, you could use | |
| :set list | |
| which will, in combination with | |
| :set listchars=... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import paho.mqtt.client as mqtt | |
| import os | |
| # The callback for when the client receives a CONNACK response from the server. | |
| def on_connect(client, userdata, flags, rc): | |
| print("Connected with result code "+str(rc)) | |
| # Subscribing in on_connect() means that if we lose the connection and | |
| # reconnect then subscriptions will be renewed. | |
| client.subscribe("hello") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import paho.mqtt.client as mqtt | |
| import os | |
| import sys | |
| # The callback for when the client receives a CONNACK response from the server. | |
| def on_connect(client, userdata, flags, rc): | |
| print("Connected with result code "+str(rc)) | |
| # Subscribing in on_connect() means that if we lose the connection and | |
| # reconnect then subscriptions will be renewed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var register = [ | |
| { | |
| name: "PENNY", | |
| value: 0.01, | |
| count: 0 | |
| }, | |
| { | |
| name: "NICKEL", | |
| value: 0.05, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const arr = [1, 2, 3, 4, 5]; | |
| const arrDoubled = arr.map((x) => 2); | |
| // arrDoubled is set to [2, 4, 6, 8, 10] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const myMap = (array, callback) => { | |
| const newArray = []; | |
| array.forEach((element) => newArray.push(callback(element))); | |
| return newArray; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // I have an array of numbers, for whom I want to find out their square roots | |
| const squares = [1, 4, 9, 16, 25, 36]; | |
| const sqrts = squares.map(Math.sqrt); | |
| // console.log(sqrts) returns [1, 2, 3, 4, 5, 6] | |
| I have another array of numbers, for whom I want their integer parts | |
| const numbers = [1.1, 2.4, 3.7, 8, 9.1, 11.2]; | |
| const integers = numbers.map(Math.floor) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present']; | |
| const bigWords = words.filter(word => word.length > 6); | |
| // console.log(bigWords) returns ["exuberant", "destruction", "present"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const myFilter = (array, callback) => { | |
| const newArray = []; | |
| array.forEach(element => { | |
| if (callback(element)) { | |
| newArray.push(element) | |
| } | |
| }) | |
| return newArray; | |
| } |
OlderNewer