Skip to content

Instantly share code, notes, and snippets.

View iamads's full-sized avatar

Abhijeet De iamads

  • Bangalore,India
View GitHub Profile
@iamads
iamads / MwNYqE.markdown
Last active October 2, 2015 20:03
MwNYqE
:set list to enable.
:set nolist to disable.
As others have said, you could use
:set list
which will, in combination with
:set listchars=...
@iamads
iamads / remote_control_client.py
Created May 11, 2017 20:33
remote_control client code c club
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")
@iamads
iamads / remote_control_client.py
Last active May 11, 2017 20:43
remote_control client code c club
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.
var register = [
{
name: "PENNY",
value: 0.01,
count: 0
},
{
name: "NICKEL",
value: 0.05,
const arr = [1, 2, 3, 4, 5];
const arrDoubled = arr.map((x) => 2);
// arrDoubled is set to [2, 4, 6, 8, 10]
@iamads
iamads / js
Created May 13, 2019 07:16
myMap
const myMap = (array, callback) => {
const newArray = [];
array.forEach((element) => newArray.push(callback(element)));
return newArray;
}
@iamads
iamads / js
Created May 20, 2019 13:40
Map Examples
// 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)
@iamads
iamads / filter1.js
Created May 20, 2019 13:48
filter1
const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
const bigWords = words.filter(word => word.length > 6);
// console.log(bigWords) returns ["exuberant", "destruction", "present"]
@iamads
iamads / myFilter.js
Created May 20, 2019 13:56
myFilter
const myFilter = (array, callback) => {
const newArray = [];
array.forEach(element => {
if (callback(element)) {
newArray.push(element)
}
})
return newArray;
}